• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception handling question

 
Tieyi Guo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to use a generic error handling page "Error.jsp" to handle all my exceptions occured from the servlet program.
The code looks like this:
<%@page isErrorPage="true" %>
<html>
<head><title>Error Message Page</title></head>
<body>
<H2>Error Message Page</H2>
<P>The Error: <%= exception.getMessage() %>
<% exception.printStackTrace(); %>
</P>
</body>
</html>
Each time, there occurs any exception in my servlet code, in the catch clause I always throws new exception, so that I can expect the error page will handle that eventually. However I run into a problem: I am using an old version of jsdk, V2.0. It does not support "RequestDiapatcher", so each time I have to use "sendRedirect" to load the next JSP page. When using "sendRedirect" I can not put the exception as an attribute into the HttpServletRequest object, how can I pass this exception to my Error.jsp page?
Thanks.
Tieyi
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty sure that HttpSessions were supported back in the Servlet 2.0 days, so you could put it in the session and retreive it back that way.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Tieyi",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
Sean
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!