display errors on custom jsp page


404 error

Sometimes customization of the 500 and 400 error pages might be desired.  To do this, configuring the  web.xml file to send these errors to the customized page(s) would help achieve the task. 

500 error



Adding the below snippet to web.xml would send all errors not handled by the application to the error page.



What if the developer wants to display the error line on the customized page? The PageContext object gives the developer access to the exception and its meta data. 


The code snippet below shows an example of displaying the exception on a cutomized jsp page.


<c:if test="${not empty pageContext.exception}"> 
  <td align=center>
	<table align=center border=0 width=100%>
        <h3 style="color:#cc0000;">
          Error: ${pageContext.exception}
        </h3> <br/>
	    Exception stack trace:<br/>
	    <c:forEach var="trace" 



Add new comment