1

In my development environment, getRemoteHost() successfully returns the client's PC/machine name. But once I deploy my application to our production environment, getRemoteHost() suddenly is returning the IP address.

Any thoughts on what needs to be done to make it always return the PC/machine name? It's a Java web application running on WAS 7.0.

Mark Logan
  • 203
  • 5
  • 19

1 Answers1

8

From the Java API

java.lang.String getRemoteHost()

Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.

Edit: You can try resolving the host name like this

InetAddress addr = InetAddress.getByName(ipString);
String host = addr.getHostName();
System.out.println(host);

Where ipString is the dotted-string form of the IP returned from the getRemoteHost() call.

TheHorse
  • 234
  • 2
  • 9