File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes server name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "server name" Watch "server name" New topic
Author

server name

Sunayna Kumar
Greenhorn

Joined: Dec 13, 2001
Posts: 1
Help! I need to get the name of the server that my servlet is running on. Would anyone have example?
Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
I believe that it is
out.println(request.getServerName());
Regards
Beksy
Biju Nair
Ranch Hand

Joined: Dec 15, 2001
Posts: 31
It is alwasys better to use the getServerPort() along with getServerName() as it will come handy if you use your port along with your server name ie. If you access your servlet as http://localhost:8080/servelt/myservlet, the getServerName() will give you only 'localhost' . In order to get the :8080 also, you have to use getServerName()+":"+getServerPort()

------------------
--:Biju:--


--: Biju Nair :--
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: server name