As I understand it, instead of putting a
<%@(protected)" %>
in each JSP page, you can put
<error-page>
<exception-type>
java.lang.Throwable</exception-type>
<location>/errorPage.jsp</location>
</error-page>
in the web.xml file. I've tried this and it appears to work as advertised.
However, I read in www.onJava.com that as of JSP 2.0, you can combine the error handling of both JSP pages and servlets because servlets now pass the exception by the same attribute name as JSP pages do: javax.servlet.error.exception. OK, but how?
All of my servlets implement doPost() which is documented to throw ServletException and IOException. Most of the errors I am throwing (and that I want my errorPage.jsp page to handle) are SQLException errors.
* If I put a catch for SQLException errors in my servlets, then nothing "escapes" the servlet to be handled by the errorPage.jsp page declared in the web.xml file.
* If I do NOT catch the SQLExceptions, then the javac compiler complains (apparently quite rightly) that an undocumented exception was thrown in reference to the ServletException and IOException exceptions doPost() is documented to throw.
* If I try to add SQLException to the doPost() throws list, the compiler complains that the overloaded method didn't originally throw SQLException.
So, what is the problem way to get exceptions thrown in a servlet conveyed to the error page recorded in the <error-page> element of the web.xml file?
Merrill Cornish
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)