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.
Because those values are coming from the request headers:
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 ]