3

I know it is quite easy to get the client's IP and server IP from the httprequest in java. Is it possible to get the browser IP of the client at any means.

Thanks in advance

Arun
  • 825
  • 4
  • 14
  • 31
  • 1
    What do you mean by 'browser IP of the client` if not the client's IP? – Andrew Mao Feb 26 '13 at 06:05
  • 2
    What is the difference between client IP and browser IP of the client? They should be the same. – Lan Feb 26 '13 at 06:05
  • client IP is the system's IP from which the req is made and the browser IP means the web connectivity IP through the req is made. – Arun Feb 26 '13 at 06:21

1 Answers1

6

As I understand correctly

You can get client IP with method

HttpServletRequest httpRequest = (HttpServletRequest) request;
String userIpAddress = httpRequest.getHeader("X-Forwarded-For");

Full quote: How to determine by what IP Address my website has been accessed?

Getting the server IP from request:

HttpServletRequest.getLocalAddr();

Full quote: Getting server address and application name

And getting the server ips can be done so:

Inet4Address.getLocalHost().getHostAddress()

Full quote: Getting the IP address of the current machine using Java

Community
  • 1
  • 1
user1111527
  • 129
  • 5