It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Request Dispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Request Dispatcher" Watch "Request Dispatcher" New topic

Request Dispatcher

Ken Truitt
Ranch Hand

Joined: Aug 23, 2007
Posts: 124
The final mock examin in hf question #56 says ("xyz") is a valid argument
to getServletContext().getRequestDispatcher(). This directly contradicts
p. 204, where a 'handwritten' note says you must provide an absolute path
to the page. The mock question says that a relative path is appropriate here or something like that. What is the underlying theory?

On a related note, if a relative path is relative to the location of the request, and if the request is being dispatched from a servlet, how could
you have a 'result.jsp' in the SAME directory?

Thanks--taking test in two hours!

Ken Truitt

SCJP 88% | SCWCD 84%
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918


Good lock by the test.

It is like this : only the dispatcher obtained from the ServletRequest can accept accept a relative path, that means you may use the paths which are not starting with "\". If you use the ServletContext you must use paths which are stating whit "\".


Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Look closer at page 204. You will see that there is no contradiction. It explains the difference between the RequestDispatcher obtained from the request and the RequestDispatcher obtained form the ServletContext.
I agree. Here's the link:
subject: Request Dispatcher
It's not a secret anymore!