aspose file tools*
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatcher