RE: How to obtain user's IP address
Thanks for the help. I tried getRemoteAddr() and getRemoteHost(). Both worked. Thanks again for the quick reply and the help. Jack -Original Message- From: William Kaufman [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 03, 2001 11:44 AM To: '[EMAIL PROTECTED]' Subject: RE: How to obtain user's IP address getRemoteUser() returns the name of the user as authenticated by the servlet engine: if you don't have authentication turned on, you'll always get back null. getRemoteAddr() and getRemoteHost() will work, though,... assuming that there's no weird address translation (like NAT) going on. You could also plow through the request headers you're getting: some user agents may tell you something useful. -- Bill K. > -Original Message- > From: Jack Li [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 03, 2001 7:35 AM > To: [EMAIL PROTECTED] > Subject: How to obtain user's IP address > > > Hello, > > 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? > > Thanks > Jack Li >
RE: How to obtain user's IP address
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() ).getHostName(); 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 [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 03, 2001 8:58 AM To: [EMAIL PROTECTED] 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 machine... 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 [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 03, 2001 7:35 AM To: [EMAIL PROTECTED] Subject: How to obtain user's IP address Hello, 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? Thanks Jack Li
RE: How to obtain user's IP address
request.getRemoteAddr() -Original Message- From: Jack Li [mailto:[EMAIL PROTECTED]] Sent: 03 May 2001 15:35 To: [EMAIL PROTECTED] Subject: How to obtain user's IP address Hello, 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? Thanks Jack Li
Re: How to obtain user's IP address
Hi Jack, Try get request.getRemoteAddr(). Good Luck ;) Francis --- Jack Li <[EMAIL PROTECTED]> wrote: > Hello, > > 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? > > Thanks > Jack Li > __ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
RE: How to obtain user's IP address
Title: 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 machine... 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 [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 03, 2001 7:35 AM To: [EMAIL PROTECTED] Subject: How to obtain user's IP address Hello, 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? Thanks Jack Li
RE: How to obtain user's IP address
getRemoteUser() returns the name of the user as authenticated by the servlet engine: if you don't have authentication turned on, you'll always get back null. getRemoteAddr() and getRemoteHost() will work, though,... assuming that there's no weird address translation (like NAT) going on. You could also plow through the request headers you're getting: some user agents may tell you something useful. -- Bill K. > -Original Message- > From: Jack Li [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 03, 2001 7:35 AM > To: [EMAIL PROTECTED] > Subject: How to obtain user's IP address > > > Hello, > > 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? > > Thanks > Jack Li >
Re: How to obtain user's IP address
They are different things. The remote user only appears if the user did enter his user id and password. The IP address you want is the remote host, so you would use request.getRemoteHost(); Un saludo, Alex. Jack Li wrote: > > Hello, > > 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? > > Thanks > Jack Li
Re: How to obtain user's IP address
I think request..getRemoteHost() will get the IP address. I do not think there is a reliable way to get the name of the user unless they have logged onto the server in some way, usually by password protecting the directories that have the server files. Andy C - Original Message - From: "Jack Li" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 03, 2001 3:35 PM Subject: How to obtain user's IP address > Hello, > > 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? > > Thanks > Jack Li >
How to obtain user's IP address
Hello, 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? Thanks Jack Li