File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the method to get the name of the server

 
Saritha Reddy
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 250
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Saritha Reddy
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic