• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

server name

 
Sunayna Kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help! I need to get the name of the server that my servlet is running on. Would anyone have example?
 
Beksy Kurian
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that it is
out.println(request.getServerName());
Regards
Beksy
 
Biju Nair
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:--
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic