Error pages get an extra object: exception
An error page is essentially the JSP that handles the exception, so the Container gives the page an extra object for the exception. You probably won’t want to show the exception to the user, but you’ve got it. In a scriptlet, you can use the implicit object exception, and from a JSP, you can use the EL implicit object ${pageContext.exception}. The object is type java.lang.Throwable, so in a script you can call methods, and with EL you can access the stackTrace and message properties.
A more explicit ERROR page (“errorPage.jsp”)

Note
Note: the exception implicit object is available ONLY to error pages with an explicitly-defined page directive: <%@ page isErrorPage=”true” %>
In other words, configuring an error page in the DD is not enough to make the Container give that page the implicit exception object!
What happens when you request “badPage.jsp”

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access