Display exception stack trace into Facelets page

Viewed 8205

I need to display exception stack trace into my JSF application error.xhtml page. I know how simple is to do it with JSP page. But with JSF 2.0 I have a problem.

In my web.xml I have defined a JSF 2.0 Facelets page as error page:

<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/faces/views/error.xhtml</location>
</error-page>

When the error occurs the I get redirected to this page. What I need is to display the stack trace of exception in this Facelets page.

I have tried to use:

<pre>
    <h:outputText value="${exception}"/>
</pre>

But I don't get any output. I have been searching the internet but I did not find a solution. How can I display the exception stack trace in the Facelets page?

EDIT:

I have just tried:

<c:forEach var="exeption" items="${exception.stackTrace}">
    <div>${exeption}</div>
</c:forEach>

<h:dataTable value="#{exception.stackTrace}"
             var="exception">
    <h:column>
        <h:outputText value="#{exception}"/>
    </h:column>
</h:dataTable>

JSTL not working and interating through datatable also not working. I am sure that exception occurs, I see it in my log files.

1 Answers
Related