File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Need Help getting Referrer IP in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Need Help getting Referrer IP in Servlet" Watch "Need Help getting Referrer IP in Servlet" New topic
Author

Need Help getting Referrer IP in Servlet

Randall Stevens
Ranch Hand

Joined: Jul 01, 2003
Posts: 65
I have a situation where an Access Controller is redirecting the request to my server. The question I have is how do I retreive the IP address of the Access Controller?
brief code examples would be appreciated, as it has been a long time since I have worked with Servlets and JSPs.
Randall
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'm assuming you're retrieving the IP address of the Controller, while you are in the responding servlet (the application the Controller redirects to).

For the originating server, you use request.getRemoteHost() and request.getRemoteAddr()

FWIW: I'm not actually sure of how to retrieve the IP address of the responding server, but you get the hostname of the responding server with request.getServerName()
 
jQuery in Action, 2nd edition
 
subject: Need Help getting Referrer IP in Servlet