File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Read Client IP Address behind Proxy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Read Client IP Address behind Proxy" Watch "Read Client IP Address behind Proxy" New topic
Author

Read Client IP Address behind Proxy

Imran Akbar
Ranch Hand

Joined: May 06, 2010
Posts: 63
Hi Ranch,

we have a requirement to fetch IP address of client machine and display it on the user page, for that i used a JSP page which does like below :



This works fine, when the system is connected directly to internet, but when its connected thru a Proxy server we receive only its proxy server IP address instead of the Client Local IP.

Is there any way we can retrieve the Client IP running behind proxy?

Thanks in advance.
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

I think there's no way to get the client IP who is behind the proxy, not atleast in servlet API


[Servlet tutorial] [Servlet 3.0 Cook Book]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39542
    
  27
Is this a client-side proxy, or a server-side proxy? If the former, then that information is most likely not available. If the latter, then there may be a custom request header (something like "X-Forwarded-For") into which the proxy puts the IP address. That's what an Apache would do that sits in front of a Tomcat.


Ping & DNS - updated with new look and Ping home screen widget
Imran Akbar
Ranch Hand

Joined: May 06, 2010
Posts: 63
Its a client side Proxy.

I appended the code



and i was able to fetch the IP of the client local machine behind proxy.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read Client IP Address behind Proxy
 
Similar Threads
Local host diffrence
Thro a proxy server
How to get the IP address of machine where the jsp file is opened
How to get the IP address of machine where the jsp file is opened
Getting IP address of User