File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "server name" Watch "server name" New topic

server name

Sunayna Kumar

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
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 Nair :--
I agree. Here's the link:
subject: server name
jQuery in Action, 3rd edition