Solved

Computer (host) name in Java (JSP page)

Posted on 2001-06-18
10
1,537 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
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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object oriented programming comparison 5 71
factorial example 4 40
login jsp example 24 49
How to convert from xls to xlsx using java 7 39
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

770 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