I applied your method to get the names. It works for some IPs. It didn't the
name of other IPs. For example, 12.5.203.134 was not converted to a name.
Any ideas?

Thanks,
Jack

-----Original Message-----
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 18, 2002 11:31 AM
To: Tomcat Users List
Subject: RE: getRemoteHost(): how to get the fully qualified name?


Howdy,
You can convert IP to host name yourself.  Here's the relevant section
of the code:

String ipAddress = "123.456.789.123";
InetAddress ia = InetAddress.getByName(ipAddress);
String hostname = ia.getHostName();

As you will by experimenting, the above has the desirable property of
working whether ipAddress is nnn.nnn.nnn.nnn or the host name.  So you
can pass whatever you get from getRemoteHost() through this.

The assumption you mention (the fully qualified name is available to the
Solaris the server is running on) is important.  The above will throw an
UnkownHostException if the assumption is broken.

Good luck,

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, July 18, 2002 11:18 AM
>To: [EMAIL PROTECTED]
>Subject: getRemoteHost(): how to get the fully qualified name?
>
>Hi all
>
>When I call the ServletRequest's getRemoteHost()-method, I get
sometimes
>the
>fully quialified name and sometimes the IP of the remote host. This is
the
>case also, if the fully qualified name is aviable to the Solaris the
server
>is running on (using nslookup). Now, is there a way to force the
>Servlet-Engine to deliver the fully qualified name instead of the IP
all
>the
>times?
>
>Thanks for any help.
>Philipp

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

<<application/ms-tnef>>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to