Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementation of getServerName in web servers

 
Jody Seigle
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Netscape Enterprise Edition 6.01 and attempting to access a Java applet. Some machines are able to see the site using a hostname (myserver) while others can only resolve it using the IP address. However, I have noticed that even though a user enters the IP address in the browser URL, a servlet calling the getServerName() method of HttpServletRequest returns the hostname of the machine (myserver).
My question is how do common webservers implement the getServerName() method. I have found that some use the Host request-header value passed by the browser. Is there a way to determine what my browser is passing for this header field?
Thanks
 
Steve Leach
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have had similar problems, specifically with Apache forwarding requests to Tomcat. Apache wasn't sending the requested host name through to Tomcat, which was then using the local machine hostname rather than the name the client requested.
will return the host name requested by the client, IF it was set by the browser. If the browser doesn't set that header then I don't think there is anything you can do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic