Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 631
mjn Avatar asked Nov 10 '11 07:11

mjn


1 Answers

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>)

like image 51
BalusC Avatar answered Oct 02 '22 22:10

BalusC