Starting with your original post, there's something you don't know and probably should. In spite of what we all assume to be true about the availability of the implicit exception object when using JSPs as error pages, that object is ALWAYS null if the JSP loads due to being mapped to an error-page element in web.xml.
What I mean is, we assume that if you write
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/errorpages/html404.jsp</location>
</error-page>
in your web.xml, then when a 404 error happens and the html404.jsp JSP loads, the implicit exception object is useful. It's not. It's null, is always null, and will never be anything other than null.
I wish it were otherwise. I also wish the documentation I find at places like java.sun.com where experts pontificate on how one can write the following code into that same html404.jsp and get something useful from the implicit exception object were actually true. It's not. Take this example, for example:
In the html404.jsp file, some people say that you can write this at the top:
<%@page isErrorPage="true" %>
and then automatically gain access to the implicit exception object and so something like this:
<%= exception.getClass().getName() %>
You can, but the only thing you get is the web container exploding all over itself complaining about the exception object being null. Why? Because it is ALWAYS null if the JSP is loaded due to a mapping in the web.xml to an HTTP error code number.
So, why do people write stuff like this? They think but don't test and spew forth "knowledge" without testing. They should test first. If they did they would find out that the only time the implicit exception object is NOT null is when the JSP error page is loaded due to another JSP containing a page directive declaring the error page like this:
<%@ page errorPage="/WEB-INF/errorpages/CustUpdateErrors.jsp" %>
For example, if JSP a.jsp has a page directive like:
<%@ page errorPage="/b.jsp" %>
and b.jsp has a directive like:
<%@page isErrorPage="true" %>
then and only then will the implicit exception object be available with a value other than null.
So, we assume that every JSP error page has a non-null implicit exception object but we are very, very wrong. Only those loaded by another JSP in the manner shown above have one. JSP error pages loaded due to a mapping in the DDs NEVER have a non-null implicit exception object. Oh, yes, the object is there but it's null. If you try to declare a variable for it like:
<% Exception exception %>
you get an error about exception already being declared, so it's definitely there and it's definitely null, and it's definitely useless, and I can't go on anymore about it.
Spoon