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?
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>
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With