-
1. Re: Getting client hostname
nickarls Jul 20, 2009 5:46 PM (in response to oneworld95)Well, you are in the 192.168.* net so perhaps it doesn't have a name that can be looked up?
-
2. Re: Getting client hostname
jeanluc Jul 20, 2009 6:39 PM (in response to oneworld95)The are many problems with that code.
At the most fundamental level, getLocalName() returns the name of the server interface through which the request was received.
local
is local to the server. From the server, the browser is theremote
user.Even then (if you tried to do the same with the remote host), you're asking the DNS servers available to the server to resolve an IP that's defined on the client. There are multiple problems with this: if private ranges are used, they are not unique at all. And in this case the client does use one. Then the OS matters, as well as whether there are multiple cards, each with its own host name. But all this is moot because the server (the HttpServletRequest object is on the server side) does not know the host name of the machine on which the HTTP request originates. Packets that reach the server may have been passed through proxies and so on. The
remote host
seen by the server is not necessarily theorigin
. The network layer thus cannot tell you that information and the HTTP protocol does not send the local machine name (for a number of reasons, security included).For security reasons, Javascript does not allow the code to read it either.
AFAIK, there are no portable solutions for what you want.
-
3. Re: Getting client hostname
oneworld95 Jul 20, 2009 6:53 PM (in response to oneworld95)Thank you, Nicklas and Jean. Very useful information and it's good to know that I wasn't losing my mind -- that the task at hand is impossible. I'll stick with IP address.