In some legacy code we had, we had a process that grab our "base" JSP files, and stick a header, footer, etc. and anything else we wanted on all the JSP files throughout the app. One thing this process added to all the JSPs was a try-catch block around the whole JSP in scriptlets. So, in the end, all our JSPs would look something like this:
<%
try
{
%>
.... all the rest of the JSP .....
<%
}
catch(Exception e)
{
Log.error(e);
}
%>
We recently got rid of this process and moved our JSPs over to use JSTL and not have any scriptlets. We created a tag that we basically wrap around each JSP do the the header, footer, etc. So now our JSPs look something like this:
<foo:page>
.... all the rest of the JSP .....
</foo:page>
In making this switch, we lost the ability to catch any exceptions that happen while loading the page. I did some looking around and found the <c:catch>
tag. I've tried to put this into our page tag, but I can't quite get it to work the way we want. I found that if I put the <c:catch>
tag just around the <jsp:doBody/>
tag in the page tag, it would catch the exception and I could do something with it. However, this won't catch any exceptions that are thrown in other parts of this outer page tag. Ideally I would enclose our entire page tag with the <c:catch>
tag, but when I do that, it doesn't seem to catch the exception. The page just stops rendering at the point the exception was thrown.
I have the same
<c:if test="${!(empty pageException)}">
ERROR!
</c:if>
after the <c:catch>
tag in both cases, but I only actually see "ERROR!" in the source when the <c:catch>
tag is immediately around the <jsp:doBody/>
Any information about this would be greatly appreciated.