Hi,
First of all, you only defined a custom error page for one type of
exception, i.e., ServletException. So if you only want to display the
exception message, you would want to wrap whatever the exception was in a
ServletException and rethrow it.
Secondly, by calling <c:catch ...>, you basically told the JSP engine that
there is an exception/error on the page, forwarding to another page at this
point will give you an IllegalStateException.
You might want to take a look at the following two directives:
<%@ page errorPage="exception.jsp" %>
<%@ page isErrorPage="true" %>
Cheers:)
-Yan
-----Original Message-----
From: Frank Burns [mailto:[EMAIL PROTECTED]
Sent: April 19, 2004 07:08
To: Tomcat Users List
Subject: Help with handling exceptions
Hi,
Please help.
What I would like to do is redirect, or forward, to another page when an
exception occurs in certain JSP pages.
I call some JSPs that utilize beans (via JSTL) that have getter methods
which perform database access. These getter methods can generate exceptions.
When they do, the JSP simply incorporates some text, indicating the
exception, into the rest of the JSP's template text.
I have included <error-page> elements in the web.xml file, like this:
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/common/exception.jsp</location>
</error-page>
And other less general exception types. But these are all just ignored. Why?
I've also tried other methods, using JSTL. For example, I catch the
exception, using <c:catch ...>,and try to forward using <jsp:forward ...>.
But I get the following response incorprated into the original called JSP:
[Exception in:../foo.jsp] Cannot forward after response has been
committed
Also, when I catch the exception and try to redirect using <c:redirect ...>
I get the original called JSP with nothing incorprated into it.
I deduce form this, that the problem is that some of the JSP page's content
has already been committed, and so the forward or redirect is prohibited. Is
this correct?
SO MY QUESTION IS: How can I achieve my objective of displaying an error
page when an exception occurs?
Thanks,
Frank.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]