views:

1596

answers:

2

What is the best way of getting some of the stack trace info, perhaps the Exeception.message onto my custom error 500 page with tomcat, spring, jsf? I'd just like the root cause of the exeception displayed.

+2  A: 

Here's the JSP syntax, which I have used with Struts. You can probably get this or similar working with JSf.

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

<!-- 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>
Peter Hilton
A: 

My solution to this was-

Declare the error jsp page to be an error page using this-

<%@ page isErrorPage="true"%>

Later in the same jsp page, you can access the "exception" object to print the stack trace to wherever you want.

<%exception.printStackTrace();%>
Keshav