aspose file tools*
The moose likes Servlets and the fly likes Get the computer name of the client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Get the computer name of the client" Watch "Get the computer name of the client" New topic
Author

Get the computer name of the client

Clarke Kent
Greenhorn

Joined: Dec 19, 2005
Posts: 14
Hi! I need to get the computer name of the machine who initiated a request.

The application is running on a company intranet.
I tried to use request.getRemoteHost(), but that function returns the actual name if im not using a proxy.. When I am using a proxy, the name of the proxy is returned and not the actual computer name.

regards,

Clarke
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If they're behind a proxy, you're not going to get that name.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Clarke Kent
Greenhorn

Joined: Dec 19, 2005
Posts: 14
yea, thats what I thought

But, is there a way to communicate with the proxy, to ask the proxy to get the name/address of the actual computer who made the request? an API or something?

regards,

clarke
Morgan Christian
Greenhorn

Joined: Apr 06, 2005
Posts: 7
Typically no.

A proxy is usually setup for a couple of reasons:

to cache internet traffic for speed enhancements or to watch 'usage'... outgoing requests from the proxy to the internet are all from the same host or small collection of hosts. The proxies themselves will not respond to your name resolution requests.

Check out http://www.squid-cache.org/ If you'd like to get a better understanding of the what/why/where of a proxy.
[ January 06, 2006: Message edited by: Morgan Christian ]

**<br />Still trying to code myself out of this wet paper bag...
Don Morgan
Ranch Hand

Joined: Jul 24, 2003
Posts: 84
If having the name of the computer is critical to your application and you really need it on the server side, one option would be to simply ask the user to enter it and then pass it along as a parameter to your servlet.

I don't know if there is any way of automating this (such as running a piece of javascript which would populate a hidden field for you with their machine's name.)


Don Morgan, Founder
www.DeveloperAdvantage.com - FREE Audiobooks for Software Developers
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
It depends. If you use Web Proxy servers then there will be proprietary property which will store the original client IP. In general you can take a look at X-Forwarded-For property.

If you are using WebLogic Proxy plugin then there is a property like WL-Proxy-Client-IP.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get the computer name of the client