This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Servlets and the fly likes Help: Client Computer Name in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Help: Client Computer Name in Servlet" Watch "Help: Client Computer Name in Servlet" New topic
Author

Help: Client Computer Name in Servlet

Shams Pakistan
Greenhorn

Joined: Jun 06, 2011
Posts: 6
Hello,

Hope you are doing fine. We have an internet facing web application which is running on WebSphere. I would like to get the Client Computer Name within one of the Servlets, I believe I can get the IP address using but the IP address would be different each time a user invokes a Servlet. I need to maintain within our database USERID and Computer Name i.e. one USERID can have multiple Computer Names.

I believe I can not get the MAC address within Servlet but I was wondering if it is possible to get client computer name.

I would really appreciate any help

Thanks
Regards
harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157
    
    1

try with
getRemoteHost(), which Returns the host name of the client sending the request. If the name is unknown, returns an empty string.
Shams Pakistan
Greenhorn

Joined: Jun 06, 2011
Posts: 6
Hello harshvardhan ojha,

Thank you very much for your prompt reply. What do you mean when by if host is unknown?

Please advise.

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14572
    
    7

You can't get the MAC address - java or not - unless the source machine is on the same LAN segment as the server, much less off the open Internet. MAC addresses don't get transported across routers.

For a variety of reasons, the source IP addresses and hostnames of client computers is unreliable, when it's available at all.


Customer surveys are for companies who didn't pay proper attention to begin with.
Shams Pakistan
Greenhorn

Joined: Jun 06, 2011
Posts: 6
Hi Tim Holloway,

I am not trying to get the network card MAC address but rather the computer name. So are you saying that request.getRemoteHost() will not return the computer name of the client correctly?

Please advise
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Help: Client Computer Name in Servlet
 
Similar Threads
Can I get the IP address and Computer Name through Servlets (Prortocal Manager) ??
How to get Mac Id of my client machine
Can I get the IP address and Computer Name through Servlets (Prortocal Manager) ??
Problem getting local ip address
IP based authentication