This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: RequestDispatcher
 
Similar Threads
sendRedirect
difference between RequestDispatcher from a ServletRequest and from a ServletContex
HTTP Status 500
servlets
How to Jsp in servlet