The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes about path elements Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "about path elements" Watch "about path elements" New topic
Author

about path elements

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
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

Joined: Mar 22, 2002
Posts: 208
Just trying to bring up to the top, does no one really know about the above?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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 ]
     
     
    subject: about path elements
     
    Threads others viewed
    class path
    contextpath,servlet path and full path
    Question on JWebUnit testing
    Mandatory DD elements for relationships?
    Servlet path, context path and path info.
    WebSphere development made easy
    without the weight of IBM tools
    http://www.myeclipseide.com