• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about path elements

 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, ranchers:
I am not clear about path elements of an ServletRequest object: request_uri, context_path, servlet_path. What is their use? Could anyone comment on these? Thanks
I checked Specs trying to find javax.servlet.include.request_uri, but it's not there. Where to find the explanations of these attributes?
[ April 12, 2002: Message edited by: rick collette ]
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just trying to bring up to the top, does no one really know about the above?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of the answer is in SRV.4.4. Assume, for example,
  • The web-app is mapped to /myapp
  • In the web-app, there's a servlet called FooServlet mapped to /foo
  • The browser requests http://www.myserver.com/myapp/foo/bar.html?param=value
  • In that case, FooServlet will be invoked with the following request attributes:
  • request.getContentPath() will return "/myapp"
  • request.getServletPath() will return "/foo"
  • request.getPathInfo() will return "/bar.html"
  • request.getQueryString() will return "param=value"
  • request.getParameter("param") will return "value"
  • request.getRequestURI() will return either "/myapp/foo/bar.html" or "http://www.myserver.com/myapp/foo/bar.html", depending on the precise format of the browser request.
  • See the spec quoted above for more details. Does this help?
    - Peter
    [ April 16, 2002: Message edited by: Peter den Haan ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic