posted 22 years ago
The doGet() method of Servlet interface can only throw the following three exceptions or their subclasses:
ServletException
IOException
RuntimeException
For custom, self-defined exceptions, wrap them in ServletException and rethrow the ServletException.
e.g:
catch( DataStoreException ex ) {
throw new ServletException( "Wrapped Excep", ex );
}
In the web.xml:
<error-page>
<exception-type>DataStoreException</exception-type>
<location>myErrorHandlingPage.jsp</location>
</error-page>
In your myErrorHandlingPage.jsp:
use the ServletException.getRootCause() to read the wrapped exception
NOTE: Even though you are throwing ServletException from doGet(), the conainer will call the ServletException.getRootCause() to find the wrapped exception and match it your <error-page> definition. BUT, remember not to have a generic <exception-type>ServletException</exception-type> in your web.xml, because then the container will just hand over your exception to this generic's corresponding location.
Hope this helps.
/hs.
<blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Lance Armstrong: "What am I on? I'm on my bike, busting my ass six hours a day. What are you on?"<hr></blockquote>