Link to home
Start Free TrialLog in
Avatar of ibro
ibro

asked on

Computer (host) name in Java (JSP page)

Hi everyone,
I want to retrieve a computer (host) name of the machine in Java on WinNT based intranet. The Java code is implemented in class, which works on JRun application server JSP (server-side).
To make myself clear I want to get the computer (host) name of the client machine, that made the request, in class, implemented in JSP page, that works in application server. (hmmm, what a sentance...). I don't want to store the IP addresses of the clients, becasuse they are dynamic.
 Hope I expressed my self clear.
  Thanks in advance.
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

How about

<%
  String hostname = request.getRemoteHost() ;
%>


Good Luck,

Tim.
Avatar of ibro
ibro

ASKER

TimYates, this does not work. It returns the same as request.getRemoteAddr() - i.e. the IP address.
try
 following code
<%
  try
  {
    String hName = InetAddress.getByName(request.getRemoteHost()).getHostName();
  }
catch(Exception dd)
{
  dd.printStackTrace();
}
%>

cheers
RJ
Avatar of ibro

ASKER

rjackman, I get the same result as request.getHostName().
There is something that I forgot to mention, there is firewall in the intranet, so all requests to application server appear to come from the firewalls IP address.
The firewall is on a different network (I can ping it, but I can not access it using the hostname).
I wonder is it possible to get the computer name in this case?
Avatar of ibro

ASKER

rjackman, I get the same result as request.getHostName().
There is something that I forgot to mention, there is firewall in the intranet, so all requests to application server appear to come from the firewalls IP address.
The firewall is on a different network (I can ping it, but I can not access it using the hostname).
I wonder is it possible to get the computer name in this case?
Probably not... :-(
It should be possible by using either signmed applet or signed javascript.  
Avatar of ibro

ASKER

Unfortunately I can not use signed applet, and javascript is not working for me. I need the host name on server side before page is sent to client.
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ibro

ASKER

I think TihYates deserves the points.
Thanks guys!