Custom 500 error page using JSF - is this a complete error message?

In my web.xml, the 500 error is being processed on the JSF page:

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

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

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

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

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

+6
source share
1 answer

It is available as a request attribute with the 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 assume you are using Facelets, for JSP you need to put it in <h:outputText> )

+8
source

Source: https://habr.com/ru/post/901186/


All Articles