Creating your own JSP exception page

If exceptions occur in JSP pages that are not handled, you can make the engine redirect to an JSP or HTML error page. You can even have access to the exception occurred (the “implicit exception object”) if you set the isErrorPage attribute to true.

A divide by zero JSP:

<%-- Redirect all uncaught exceptions to errorpage.jsp --%>
<%@ page errorPage="errorpage.jsp"%>

   int h = 10 / 0;


<%-- provides access to the implicit exception object --%>
<%@ page isErrorPage="true" %>
   <h3>An error occurred!</h3>

Test it out here:
Divide by zero JSP