If you set up a JSP called for example
"myError.jsp" with this directive
<%@ page isErrorPage="true" %>
and then use <%@ page errorPage="myError.jsp" %>
in other pages, then any runtime exceptions in a JSP will cause
"myError.jsp" to be executed. In this page you can do the logging.
I would <jsp:forward page="LoggingServlet"/> to a
Servlet and do the logging there since I prefer not to have too much
Java code in a JSP.