Exception Handling in JSP Pages
 
How to catch Exceptions?
 
We can catch exceptions in a JSP page like we would do in other Java classes. Simply put the code which can throw an exception/s between a try. Catch block.
<%
try {
// Code which can throw can exception
} catch(Exception e) {
// Exception handler code here
}
%>
 
There is yet another useful way of catching exceptions in JSP pages.
 
We can specify error page in the 'page' directive. Then if any exception is thrown, the control will be transferred to that error page where we can display a useful message to the user about what happened and also inform our sysadmin about this exception depending obviously on how important it may be.