JSP error pages

Is there a way to create a custom error page while storing the HTTP error code (without logging the error on an error page that itself has a 200 code)? Can this be done with web.xml or can I do it directly in the JSP?

If I submit an HTTP error code using response.sendError, no other text appears on the page. I can get the text on the page using out.println (), but it can't seem to print the html, just basic text.

0


source to share


2 answers


You should use response.setStatus (int statusCode) to set the status to 404 while still allowing you to submit your error page.



+1


source


Yes in your web.xml you can customize error codes with "error-page" tag and "error code" and "location" children



<error-page>
   <error-code>400</error-code>
   <location>/WEB-INF/jsp/errorpages/errorPage400.jsp</location>
</error-page>

      

+2


source







All Articles