"String host_name = null " in your code, but cann't host_name show up again the rest of code, can you explain it ?
Thanks! Franco -----Original Message----- From: tony [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 25, 2001 8:02 PM To: [EMAIL PROTECTED] Subject: Re: getRemoteAddr() vs getRemoteHost() Hi there, hopefully, I can help u out. Try this method below... public static String getHost(String ip_addr) { String host_name = null; try { ip_addr = InetAddress.getByName (ip_addr).getHostName(); }catch (UnknownHostException uhe) { } catch (NullPointerException npe) { } return ip_addr; } For Example, (if you wanna retrieve the host name of 216.115.102.77 ) import java.net.*; public class TestIp{ public static String getHost(String ip_addr) { String host_name = null; try { ip_addr = InetAddress.getByName (ip_addr).getHostName(); }catch (UnknownHostException uhe) { } catch (NullPointerException npe) { } return ip_addr; } public static void main(String[] args){ System.out.println(getHost("216.115.102.77")); } } if u get "w5.snv.yahoo.com", BINGO ! :) if not, sorry. bye- Wolfgang. =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
