I've registered an error page:
<error-page>
<error-code>401</error-code>
<location>/WEB-INF/exceptions/401.jsp</location>
</error-page>
I trigger an error in my Servlet:
response.sendError(401, "message here");
401.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8" isErrorPage="true"%>
<!DOCTYPE html>
<html>
...
<body>
<h1>Unauthorized (401)</h1>
<p><%= exception.getMessage() %></p>
</body>
</html>
Unfortunately, only the 'generic' 401 page is displalyed.
I've restarted the application and Tomcat, but no change.
What am I missing?
** edit 0 **
I included the JSP file's code.
It appears that the issue is with the <%= exception.getMessage() %>
code. If it is removed, the custom page displays as expected. If it is present, the 'generic' message is displayed.
I substituted this JSTL ${pageContext.errorData.throwable.message}
. The custom 401 page is displayed, but the message is blank.