Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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


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 ?

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");
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:
subject: RequestDispatcher
It's not a secret anymore!