Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

why getServerName() is part of ServletRequest?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why getServerName() and getServerPort() methods are added as part of ServletRequest instead of ServletContext.I mean we will get Server info by ServletContext,and these provide info about Server.So why not these provide as part of ServletContext.
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because those values are coming from the request headers:


SRV.14.2.16.1 Methods


getServerName()
public java.lang.String getServerName()
Returns the host name of the server to which the request was sent. It is the
value of the part before ":" in the Host header value, if any, or the resolved

server name, or the server IP address.
Returns: a String containing the name of the server

getServerPort()

public int getServerPort()
Returns the port number to which the request was sent. It is the value of the
part after ":" in the Host header value, if any, or the server port where the cli-
ent connection was accepted on.

Returns: an integer specifying the port number




[ January 14, 2005: Message edited by: Ben Souther ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!