Three ways to catch errors:
To redirect to an error page:
1. declare one
jsp as being the error page:
<%@ page isErrorPage="true" %>
2. declare the error-risky page as having an error page :
<%@ page errorPage="error.jsp" %>
Where error.jsp is the name of the first jsp (in 1.)
Yet another way to redirect, but works for the whole web app:
Declare in DD the exception-type to catch or the error code to catch and associate to a page:
<error-page>
<exception-type> fully qualified excpetion class </exception-type>
<location>/error.jsp</location>
</error-page>
And finally, the c:catch JSTL tag :
<c:catch var="errVar">
risky code
<c:catch>
var is optional. If defined, it may be used AFTER the catch block to get error message like this :
${errVar.message}