wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "RequestDispatcher" Watch "RequestDispatcher" New topic
Author

RequestDispatcher

Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
What is the difference between a RequestDispatcher object obtained from the Request object and the RequestDispatcher object obtained from the ServletContext ?


SCWCD 1.4, SCJP 1.4
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
The ServletRequest.getRequestDispatcher() method can accept paths relative to the current request (paths that don't start with a slash).

Paths passed to the ServletContext.getRequestDispatcher() method must start with a slash (and are therefore relative to the web app root.)
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
You MUST use context relative URLs with the one from the ServletContext (beginning with /), while you MAY use a URL relative to the current servlet (ommitting the /) as well as context relative with that from ServletRequest.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: RequestDispatcher
 
Similar Threads
RequestDispatcher!!!
A question on RequestDispatcher
Guidelines for Servlet Design?
Request Dispatcher
What is the diff between a RequestDispatcher object obtained from Request & Context