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]

Reply via email to