?
Solved

Computer (host) name in Java (JSP page)

Posted on 2001-06-18
10
Medium Priority
?
1,609 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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 80 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

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