0

I have a webpage behind a load balancer, and I want to display the user (for troubleshooting purposes) the IP of the actual node that the user is connected to (will be the same for a while due to sticky session)

I'm sure it's a very trivial question, but I want to be sure, what Java API should be used for that? will all APIs return me the request host? or will it be server dependent?

Eran Medan
  • 44,555
  • 61
  • 184
  • 276

1 Answers1

3

InetAddress.getLocalHost().getHostName() will give you the name of the server you are on. InetAddress.getLocalHost().getHostAddress() will give the IP Address of the server you are on.

Dani
  • 3,744
  • 4
  • 27
  • 35
rfeak
  • 8,124
  • 29
  • 28