0

My Scenario: Client is opening jsp2 page window by clicking button from jsp1 page.

I want to get Client's IP in jsp2 page

I have tried to use below mentioned code:

String clientip = request.getRemoteAddr();

but it's getting IP of jsp1 page

For getting IP I can't pass parameters from jsp1 page.

Can anyone help me on this issue?
Your help is much appreciated.
Best Regards.

ABD
  • 113
  • 3
  • 12

2 Answers2

0

There is no such thing as IP of jsp1 page - JSP page does not have an IP address. According to ServletRequest.getRemoteAddr() javadoc, the method returns the Internet Protocol (IP) address of the client or last proxy that sent the request - i.e. if you have a proxy in front of your servlet container (e.g. Apache HTTPD), you'll get IP address of that proxy.

See this answer for how to see 'through' the proxy and get the real IP address of the client.

Community
  • 1
  • 1
Jozef Chocholacek
  • 2,874
  • 2
  • 20
  • 25
0

This code is working in my case:

 String ip = request.getRemoteHost();
ABD
  • 113
  • 3
  • 12