This week's book giveaway is in the Agile and Other Processes forum.We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!See this thread for details.

*** RequestDispatcher doubt ***

Niranjan Deshpande

Ranch Hand

Posts: 1277

posted 10 years ago

If we use "ServletRequest" to get "RequestDispatcher",the path it can start with "/" or relative to the request . If it starts with "/",it means the component exists in a location which is relative to root and if it does not start with "/", it means the component is placed relative to original request

component is placed relative to original request

please explain the above with a directory structure and URLs

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]Performance is a compulsion, not a option, if my existence is to be justified.

1. The getRequestDispatcher method takes a String argument describing a path within the scope of the ServletContext. This path must be relative to the root of the ServletContext and begin with a �/� 2. The method uses the path to look up a servlet, using the servlet path matching rules and returns the resulting object. 3. To allow RequestDispatcher objects to be obtained using relative paths that are relative to the path of the current request (not relative to the root of the ServletContext), the getRequestDispatcher method is provided in the ServletRequest interface. 4. The servlet container uses information in the request object to transform the given relative path against the current servlet to a complete path. For example, in a context rooted at �/� and a request to /garden/tools.html, a request dispatcher obtained via ServletRequest.getRequestDispatcher("header.html") will behave exactly like a call to ServletContext.getRequestDispatcher("/garden/header.html").