This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes *** RequestDispatcher doubt *** Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "*** RequestDispatcher doubt ***" Watch "*** RequestDispatcher doubt ***" New topic

*** 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
will behave exactly like a call to

Hope this explains the whole thing.

SCJP 1.4 (86%)<br />SCWCD 1.4 (86%)<br />----------<br />If You dont succeed at first time,call it Version 1.0 !!!
subject: *** RequestDispatcher doubt ***