• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1726
  • Last Modified:

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.
0
ibro
Asked:
ibro
1 Solution
 
TimYatesCommented:
How about

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


Good Luck,

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

cheers
RJ
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ibroAuthor Commented:
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?
0
 
ibroAuthor Commented:
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?
0
 
TimYatesCommented:
Probably not... :-(
0
 
venkat2000120699Commented:
It should be possible by using either signmed applet or signed javascript.  
0
 
ibroAuthor Commented:
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.
0
 
TimYatesCommented:
But if all you have is the IP address of the firewall, then this isn't possible (especially if the firewall is on another network)...

Unless there is some way to get the firewall to resolve the ip address...

Tim.
0
 
ibroAuthor Commented:
I think TihYates deserves the points.
Thanks guys!
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now