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


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

RequestDispatcher

Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
There is an objective like this.
How to use RequestDispatcher to forward the request to an error page

Can anybody explain what does this mean ?

regards,
Sam
Kyle Tang
Ranch Hand

Joined: Aug 22, 2002
Posts: 78
when an error-page is triggered, servlet container will put a few attributes in the HttpServletRequest object.
I might forget some of the attribute names. these are what I remember:
Throwable javax.servlet.error.exception
Integer javax.servlet.error.status_code (or error_code?)
String javax.servlet.error.servlet_url
String javax.servlet.error.http_method
(I might be putting a wrong name above, please check the Servlet spec.)
If you use RequestDispatcher to forward to an error page, you need to do this:
RequestDispatcher dispatch = request.getRequestDispatcher(...);
request.setAttribute("javax.servlet.error.error_code", new Integer"404");
request.setAttribute(...);
...
dispatch.forward();
this is not a recommended way to trigger error handling.


Kyle Tang<br />SCJP 91<br />SCWCD 96<br />SCBCD 95
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatcher