mjn
mjn

Reputation: 36654

Custom 500 error page using JSF - is the full error message available?

In my web.xml the 500 error is handled by a JSF page:

<error-page>
    <error-code>500</error-code>
    <location>/errorpage.html</location>
</error-page>

If the container handles a 500 error and calls this JSF page, is there a request parameter or body content in the request which contains the full error message?

So for example if I use this code in a Servlet to provide a error description with the 500 error:

response.sendError(HttpURLConnection.HTTP_INTERNAL_ERROR, "Some error message");

is there a standard way to get the text "Some error message" from the request?

Upvotes: 6

Views: 6652

Answers (1)

BalusC
BalusC

Reputation: 1108722

It's available as request attribute with the key of RequestDispatcher#ERROR_MESSAGE which is "javax.servlet.error.message". So, this should do:

<p>The error message is: #{requestScope['javax.servlet.error.message']}</p>

(note: I'm assuming that you're using Facelets; for JSP you'd have to put it in <h:outputText>)

Upvotes: 12

Related Questions