Check java.net.NetworkInterface, it lets you enumerate all interfaces
and addresses / interface. Discard loopback 127.0.0.1 and private
addresses (see rfc 1918), with any luck there should be one address
remaining. Of course, that is assuming your machine is directly exposed
to the internet.

http://java.sun.com/j2se/1.5.0/docs/api/java/net/NetworkInterface.html
http://www.ietf.org/rfc/rfc1918.txt

Or you could use ServletRequest.getLocalAddr(), it's simpler but
obviously unavailable until someone actually connects to your server, so
it's unusable with any kind of eager initialization.

Greetings, Lilianne E. Blaze

Waseem Azhar wrote:
> Hi,
>
> How do I obtain the IP address of the machine (where the tomcat tomcat
> server in running) ? My web app is deployed on tomcat server and I want to
> know the Ip address of the server in my application.
>
> Thanks in advance.
>
> -Azhar
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to