User IP address
How do I get the user IP address? I only get the IP of the server. Thanks -- They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety. -- Benjamin Franklin (1755) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: User IP address
HttpServletRequest.getRemoteAddr() -Tim Jarl Skogsholm wrote: How do I get the user IP address? I only get the IP of the server. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: User IP address
if the users are behind a proxy use the following approach: String endIp = req.getRemoteAddr(); String endIpfoward = req.getHeader(X-Forwarded-For); //the user is behind a proxy if (endIpfoward != null) { endIp = endIpfoward; } so you will get the real ip address anyway, even if it's behind a proxy... Emerson Tim Funk wrote: HttpServletRequest.getRemoteAddr() -Tim Jarl Skogsholm wrote: How do I get the user IP address? I only get the IP of the server. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Emerson Cargnin Analista de Sistemas - Gerente Regional - Tubarão Setor de Desenvolvimento de Sistemas - TRE-SC tel : (048) - 251-3700 - Ramal 3181 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
User IP Address
Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark
Re: User IP Address
Mark Muffett wrote: Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark Hi :-) I suggest you try: - javax.servlet.ServletRequest.getRemoteAddr() - javax.servlet.ServletRequest.getRemoteHost() but sometimes they don't work, for example: - there is a HTTP-proxy between client and Servlet - client is behind firewall - ... Bo June 22, 2001
RE: User IP Address
request.getRemoteAddr() will get the user's IP Address requet.getRemoteHost() will do DNS lookup on the address request.getHeader(Referrer) is the referrer, I believe. Randy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 10:55 AM To: [EMAIL PROTECTED] Subject: RE: User IP Address Should be able to query the HTTPServletRequest object to get this information, try looking there -Original Message- From: Mark Muffett [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 9:50 AM To: [EMAIL PROTECTED] Subject: User IP Address Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark
RE: User IP Address
Should be able to query the HTTPServletRequest object to get this information, try looking there -Original Message-From: Mark Muffett [mailto:[EMAIL PROTECTED]]Sent: Friday, June 22, 2001 9:50 AMTo: [EMAIL PROTECTED]Subject: User IP Address Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark
Re: User IP Address
one thing to note that i discovered the hard way.. referrer should be spelled as so: request.getHeader(referer) not sure why... but i beat my head against the wall for an hour... until i tried the alternate spelling... Cj Randy Layman wrote: request.getRemoteAddr() will get the user's IP Address requet.getRemoteHost() will do DNS lookup on the address request.getHeader(Referrer) is the referrer, I believe. Randy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 10:55 AM To: [EMAIL PROTECTED] Subject: RE: User IP Address Should be able to query the HTTPServletRequest object to get this information, try looking there -Original Message- From: Mark Muffett [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 9:50 AM To: [EMAIL PROTECTED] Subject: User IP Address Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark -- Corey A. Johnson Creative Network Innovations http://www.cniweb.net/ 1-800-CNi-5547 ** 1-321-259-1984
Re: User IP Address
Brilliant! works perfectly. Now to write the logging program... Thanks Mark - Original Message - From: Randy Layman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 22, 2001 3:23 PM Subject: RE: User IP Address request.getRemoteAddr() will get the user's IP Address requet.getRemoteHost() will do DNS lookup on the address request.getHeader(Referrer) is the referrer, I believe. Randy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 10:55 AM To: [EMAIL PROTECTED] Subject: RE: User IP Address Should be able to query the HTTPServletRequest object to get this information, try looking there -Original Message- From: Mark Muffett [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 9:50 AM To: [EMAIL PROTECTED] Subject: User IP Address Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark
RE: User IP Address
Brilliant! works perfectly. Now to write the logging program... You might want to check out Randy's request logging interceptor see attachment... --- Michael Wentzel Software Developer Software As We Think - http://www.aswethink.com attch: Since a number of people have asked for it over the past and I had a little extra time, I wrote a RequestInterceptor that logs requests. Its still a little rough and have room for some performance improvements, but I believe that it is functional. You can view the documentation and download it from: http://www.aswethink.com/employees/randy/tomcat/requestLogger.html If you have any feedback, please send it directly to me so that we don't clutter up the list.
RE: User IP Address
Does the case matter here, or just dropping the r? Randy -Original Message- From: Corey A. Johnson [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 11:58 AM To: [EMAIL PROTECTED] Subject: Re: User IP Address one thing to note that i discovered the hard way.. referrer should be spelled as so: request.getHeader(referer) not sure why... but i beat my head against the wall for an hour... until i tried the alternate spelling... Cj Randy Layman wrote: request.getRemoteAddr() will get the user's IP Address requet.getRemoteHost() will do DNS lookup on the address request.getHeader(Referrer) is the referrer, I believe. Randy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 10:55 AM To: [EMAIL PROTECTED] Subject: RE: User IP Address Should be able to query the HTTPServletRequest object to get this information, try looking there -Original Message- From: Mark Muffett [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 9:50 AM To: [EMAIL PROTECTED] Subject: User IP Address Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark -- Corey A. Johnson Creative Network Innovations http://www.cniweb.net/ 1-800-CNi-5547 ** 1-321-259-1984
Re: User IP Address
case matters as well i believe.. Cj Randy Layman wrote: Does the case matter here, or just dropping the r? Randy -Original Message- From: Corey A. Johnson [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 11:58 AM To: [EMAIL PROTECTED] Subject: Re: User IP Address one thing to note that i discovered the hard way.. referrer should be spelled as so: request.getHeader(referer) not sure why... but i beat my head against the wall for an hour... until i tried the alternate spelling... Cj Randy Layman wrote: request.getRemoteAddr() will get the user's IP Address requet.getRemoteHost() will do DNS lookup on the address request.getHeader(Referrer) is the referrer, I believe. Randy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 10:55 AM To: [EMAIL PROTECTED] Subject: RE: User IP Address Should be able to query the HTTPServletRequest object to get this information, try looking there -Original Message- From: Mark Muffett [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 9:50 AM To: [EMAIL PROTECTED] Subject: User IP Address Anyone know if it's possible to use JSP / Tomcat to get user IP addresses (for logging)? - or any other user info that might go to the server (like referrer)? Ideas and sample code would be very welcome... Thanks Mark -- Corey A. Johnson Creative Network Innovations http://www.cniweb.net/ 1-800-CNi-5547 ** 1-321-259-1984 -- Corey A. Johnson Creative Network Innovations http://www.cniweb.net/ 1-800-CNi-5547 ** 1-321-259-1984
Re: User IP Address
Hi Corey, FYI, that is the way the header has been misspelt in the HTTP RFCs one thing to note that i discovered the hard way.. referrer should be spelled as so: request.getHeader(referer) not sure why... but i beat my head against the wall for an hour... until i tried the alternate spelling... Cj -- [EMAIL PROTECTED] Computer Science and Engineering, UNSW