tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yuval Perlov <yu...@r-u-on.com>
Subject Re: Getting the tomcat server IP
Date Sat, 21 Feb 2009 18:44:16 GMT
You are right, should have been: request.getLocalAddr() - my bad.

Also, from the socket object you can always call  
socket.getLocalAddress() on an outgoing connection. This is useful if  
you want to make sure you are getting the IP for a particular network.

Yuval

On Feb 21, 2009, at 7:57 PM, Rusty Wright wrote:

> Yuval, wouldn't that give you the client's address?  I thought she  
> wanted the server's ip address, with the added wrinkle that her  
> server has multiple network interfaces.
>
>
> Yuval Perlov wrote:
>> request.getRemoteAddr();
>> You can only get your actual IP after opening a connection. Of  
>> course it can change depending on where the connection is coming  
>> from.
>> Alternatively you can open a connection to a known public server,  
>> and figure out your IP using the resulting socket. If you are going  
>> through a NAT this might not be your actual IP but the IP on your  
>> side of the NAT.
>> Yuval Perov
>> On Feb 20, 2009, at 2:21 AM, Natalie Forood wrote:
>>> Hello,
>>>
>>> Can you tell me how I can get the IP address of the interface that  
>>> is running Tomcat?  I can't use localhost, I need the IP of the  
>>> physical interface.
>>>
>>> Thanks,
>>> Natalie
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message