This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes *** RequestDispatcher doubt *** Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "*** RequestDispatcher doubt ***" Watch "*** RequestDispatcher doubt ***" New topic
Author

*** RequestDispatcher doubt ***

Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
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.
sarang bharambe
Ranch Hand

Joined: Apr 01, 2005
Posts: 40
Hey Niranjan,

As per servlet specs:

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").

Hope this explains the whole thing.
Regards,
sarang


SCJP 1.4 (86%)<br />SCWCD 1.4 (86%)<br />----------<br />If You dont succeed at first time,call it Version 1.0 !!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: *** RequestDispatcher doubt ***
 
Similar Threads
HFSJ ERRATA ??? pg 343
what is this for: setLocationRelativeTo()
ServletRequest RequestDispatcher
HFSJ Book and Errata
sendRedirect