getting client hostname

Hi, I am developing a web application, and It is needed to get the remote hostname that is submitting a form. The IP address is not helpful because the network where is going to be implemented uses DHCP and the hostnames are registered in the database. I have used request.getRemoteHost and the class InetAddress and its method getHostName, but the first always returns the IP, and the second not always returns the hostname.

Any Idea, (even if someone knows how to get fhis through JavaScript, or VBScript or anyway)

Thanks a lot.

[550 byte] By [Chidoa] at [2007-11-27 5:51:04]
# 1

This is indeed not always possible through the ServletRequest. It would cost one DNS lookup, which might take a long time.

The InetAddress API ought to be sufficient: http://java.sun.com/j2se/1.5.0/docs/api/java/net/InetAddress.html

InetAddress inetAddress = InetAddress.getByName("127.0.0.1");

String hostName = inetAddress.getHostName();

It lookups the hostname through the DNS as specified on the local machine. If a hostname isn't being resolved correctly, then you may change the DNS server setting.

BalusCa at 2007-7-12 15:39:32 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
I have read that if the hostname can't be gotten is for security reasons, so is it necessary to grant a special privilege from the DNS server to the web server?
Chidoa at 2007-7-12 15:39:32 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...