This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher

 
Mathew Sam
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 78
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic