aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes what is the method to get the name of the server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "what is the method to get the name of the server" Watch "what is the method to get the name of the server" New topic
Author

what is the method to get the name of the server

Saritha Reddy
Greenhorn

Joined: Jun 17, 2004
Posts: 8
Hi
My server Ip address is say 172.33.33.345
I have a name for this server say "xxxx"
if I use request.getServerName() I get the IPAddress
I want the server name not the IPAddress.
Can some one help me with a method name that returns the name of the server


I appreciate your help
Thanks in advance
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
Hello,
There are many ways to do it . You can use JMX for the same but the below approach is much more simpler.


import java.net.InetAddress;

InetAddress address = InetAddress.getLocalHost();
String hostName = address.getHostName();


Hope it helps.


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Saritha Reddy
Greenhorn

Joined: Jun 17, 2004
Posts: 8
Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the method to get the name of the server
 
Similar Threads
how to know ip address in JSP
finding IP address
getting ip address
Use hostname such as "abc.myname.xyz" instead of "localhost:8080" to access Tomcat
Getting Server Name if the Current Managed Server on a Cluster Env