Solved

Computer (host) name in Java (JSP page)

Posted on 2001-06-18
10
1,529 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
Comment Utility
How about

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


Good Luck,

Tim.
0
 
LVL 3

Author Comment

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

Expert Comment

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

cheers
RJ
0
 
LVL 3

Author Comment

by:ibro
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 35

Expert Comment

by:TimYates
Comment Utility
Probably not... :-(
0
 
LVL 2

Expert Comment

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

Author Comment

by:ibro
Comment Utility
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
Comment Utility
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
Comment Utility
I think TihYates deserves the points.
Thanks guys!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now