How to get client browser's ip address

L

Luca Paganelli

I don't have the documentation at hand actually
but I remember there's a method of HttpServletRequest
like getRemoteHost().

So from your JSP page you can simply call
request.getRemoteHost()
as "request" object is automatically given by J2EE framework!
 
G

Grant Wagner

Luca said:
I don't have the documentation at hand actually
but I remember there's a method of HttpServletRequest
like getRemoteHost().

So from your JSP page you can simply call
as "request" object is automatically given by J2EE framework!

Nitpick: that does _not_ give you the IP address of "client's
browser", since the client's browser has no IP address associated
with it.

More to the point: It does _not_ give you the IP address of the
"user agent's host connecting to the server for that request". It
gives you the IP address of the "host connecting to the server
for that request". Sometimes those two values (the IP address of
the user agent's host and the host connecting to the server) are
the same. Very often they are not.

You will not be able to uniquely identify the IP address of any
user agent's host if that user agent is visiting your server
through a proxy, or from behind NAT.

When I connect to a Web site from home, REMOTE_ADDR does not
report the IP address of the host running my user agent
(192.168.0.192), nor does it show the external IP address
assigned by my ISP. When I connect to a Web site from home,
REMOTE_ADDR returns my ISP's proxy server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top