Get stack trace information in tomcat custom error 500 pages

What is the best way to get some stack trace information, maybe Exeception.message to my own 500 error page using tomcat, spring, jsf? I would just like the main reason for the manifestation of exeception.

+3
source share
2 answers

Here is the JSP syntax that I used with Struts. You can probably get this or similar work with JSf.

<!-- Get the exception object -->
<c:set var="exception" value="${requestScope['javax.servlet.error.exception']}"/>

<!-- Exception message(s) -->
<p>${exception.message}</p>
<p><c:if test="${not empty exception.cause.message}">${exception.cause.message}</c:if></p>

<!-- Stack trace -->
<jsp:scriptlet>
exception.printStackTrace(new java.io.PrintWriter(out));
</jsp:scriptlet>
+5
source

My solution for this was -

Declare jsp error page as error page using this -

<%@ page isErrorPage="true"%>

jsp "", , .

<%exception.printStackTrace();%>
0

Source: https://habr.com/ru/post/1705848/


All Articles