• Post Reply Bookmark Topic Watch Topic
  • New Topic

Determining the app server's hostname.  RSS feed

 
James Tillington
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible, at runtime, to determine the server's hostname? For example, I have three servers (load balanced) and I would like to be able to print the hostname to aid in debugging.

Thoughts?

I tried using the servletContext object in javax.http.servlet. The getServerInfo method returns the name of the container (weblogic, tomcat, etc...) but not the hostname. I enumerated through the servlet attributes, also with no luck. I also tried the getRealPath method... still no luck.

Thanks,
Marc
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess HttpServletRequest does not have any method for that.

May be you can try reading the environment variables of server using

which will return map
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
James Tillington
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Bear. I knew it had to be possible...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!