tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Nuss" <>
Subject RE: How to obtain user's IP address
Date Thu, 03 May 2001 18:06:35 GMT
You'll need to go to the Javasoft site (Developer Connection) and
search the database for problems related to reverse domain lookups.
For instance, some wierd things have been done w/ RMI for getting
domain (I assume you want user AND domain).


I myself used

    String fullUserName = InetAddress.getByName(request.getRemoteAddr()

because I noticed that getRemoteAddr always works since the address is
right there in the TCP/IP packet.


However, the above apis are using InetAddress which in turn
invokes (I believe) the Solaris reverse domain lookup scripts/functions
thru native code.  Please refer to documents on JDC or step thru the above
apis in the debugger (JSwat).

 -----Original Message-----
From: Steven Parks []
Sent: Thursday, May 03, 2001 8:58 AM
Subject: RE: How to obtain user's IP address

The name of the 'user' would be dependent on the machine which called the
servlet.  Where did you get request.getRemoteUser()??
There is a getRemoteHost and getRemoteAddr method to the ServletRequest
class which will return either the host or IP-Address of the calling
public abstract String getRemoteHost() 
Returns the fully qualified host name of the agent that sent the request.
Same as the CGI variable REMOTE_HOST. 
Never having tried it myself, cannot say if it is reliable under all
browsers or calling contexts.... 
-----Original Message----- 
From: Jack Li [] 
Sent: Thursday, May 03, 2001 7:35 AM 
Subject: How to obtain user's IP address 

I need to know who visits my web page. In jsp, I got "null" when I used 
"request.getRemoteUser()". Then any other mehods can obtain user's name or 
IP address? 
Jack Li 

View raw message