这是我在Struts中使用过的JSP语法。您可能可以使用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>