wood burning stoves 2.0*
The moose likes Servlets and the fly likes IP address retrieval Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "IP address retrieval " Watch "IP address retrieval " New topic
Author

IP address retrieval

sunil kumre
Ranch Hand

Joined: Dec 23, 2000
Posts: 64
Hello
I'm writing a servlet which will be put on our server.
A client can make a request for this servlet.I would like to retrieve the IP address of the client machine(which could be behind a firewall).What code should be put in the servlet to make this happen.
Thanks in advance
Sunil
Manjunath Subramanian
Ranch Hand

Joined: Jul 18, 2001
Posts: 236

You can make use of the method getRemoteAddr() declared in the
ServletConfig interface,implemented by HttpServletRequest class
This method will return the string equivalent of the client
IP address.The firewall shouldn't be a problem.
Hope this helps,
Manjunath
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: IP address retrieval
 
Similar Threads
Getting IP and location of a client
Difference between request.getRemoteAddr() and request.getLocalAddr()?
Track client request
Get the website name in the sevlet
IP address retrieval