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
  • 43,837
  • 59
  • 177
  • 273

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,626
  • 4
  • 26
  • 35
rfeak
  • 7,958
  • 28
  • 27