Meaningless Drivel is fun!*
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
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
 
Similar Threads
should we open the db.db at Server startup?
ActiveObjectInitException
configuring Microsoft SQL Server 2005
How to find server name
DataSource creation in WSAD 5