• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getRequestURI() vs getRequestURL()

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public java.lang.String getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String.
For example: First line of HTTP request Returned Value
POST /some/path.html HTTP/1.1 /some/path.html
GET http://foo.bar/a.html HTTP/1.0 /a.html
HEAD /xyz?a=b HTTP/1.1 /xyz
why is it in second case it is just /a.html when it says from the protocol name up to the query string
what is the difference between getRequestURI() vs getRequestURL() other than the returntype
 
Ricardo Cortes
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the wording in the spec. isn't too clear. It should say "this method returns the URI path associated with the request" (taken from WROX Java Server Programming). So the protocol and the domain are not included in the return string.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic