In Jsp exception is handled as we are provided with two attributes of page directive:
errorPage
isErrorPage
On Page from where we can get runtime exception, we can specify the errorPage as shown below:
<%@ page errorPage="error.jsp" %>
And on error.jsp page we need to add below page directive:
<%@ page isErrorPage="true" %>
And then on this page we can display cutomized message or exception details.
<h3>Some Exception occured!</h3> Exception is: <%= exception %>
Other then using this jsp provided way of handling exceptions we can use try catch block in scriptlets.
<% try{ } catch(Exception e){ } %>