Solved

Computer (host) name in Java (JSP page)

Posted on 2001-06-18
10
1,575 Views
Last Modified: 2008-03-17
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
Comment
Question by:ibro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 6201868
How about

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


Good Luck,

Tim.
0
 
LVL 3

Author Comment

by:ibro
ID: 6201932
TimYates, this does not work. It returns the same as request.getRemoteAddr() - i.e. the IP address.
0
 
LVL 3

Expert Comment

by:rjackman
ID: 6202119
try
 following code
<%
  try
  {
    String hName = InetAddress.getByName(request.getRemoteHost()).getHostName();
  }
catch(Exception dd)
{
  dd.printStackTrace();
}
%>

cheers
RJ
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:ibro
ID: 6202286
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
 
LVL 3

Author Comment

by:ibro
ID: 6202295
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
 
LVL 35

Expert Comment

by:TimYates
ID: 6202329
Probably not... :-(
0
 
LVL 2

Expert Comment

by:venkat2000120699
ID: 6203593
It should be possible by using either signmed applet or signed javascript.  
0
 
LVL 3

Author Comment

by:ibro
ID: 6205459
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
 
LVL 35

Accepted Solution

by:
TimYates earned 40 total points
ID: 6205756
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
 
LVL 3

Author Comment

by:ibro
ID: 6207327
I think TihYates deserves the points.
Thanks guys!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question