This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes dispatching requests to servlets 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 "dispatching requests to servlets" Watch "dispatching requests to servlets" New topic

dispatching requests to servlets

Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
When dispatching requests to servlets using request.getRequestDispatcher("/servlet/servletX") how is the file structure evaluated?? since while using request to get the dispatcher the current location of the request is important...

for example:
context: catalog
current request: catalog/user/create.jsp
What happens if I try to dispatch the request to the path "/servlet/servletX"?? what happens if I try to dispatch the request to the path "servlet/servletX"??
thanks, in advance...
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3527
If you give a relative path (one that does not start with /)such as getRequestDispatcher("hello.jsp"), the the path of the current jsp is important. In this case, hello.jsp has to be inthe same directory as the current jsp. Otherwise, the path is evaluated from the document root and does not depend on the path of the current jsp.

Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
I agree. Here's the link:
subject: dispatching requests to servlets
It's not a secret anymore!