Pages

Thursday, November 11, 2010

JavaEE: Custom Error Messages

Customizing HTML error Messages by error-code such as 404,403,500 error pages.

a.    Create your own custom HTML error page '403.html','403.html','403.html','404.html','408.html and ''500.html'.
b.  Edit web.xml file to add the below XML snippet
<error-page>
             <error-code>403</error-code>
             <location>/403.html</location>
</error-page>
<error-page>
             <error-code>404</error-code>
             <location>/404.html</location>
</error-page>
<error-page>
             <error-code>408</error-code>
             <location>/408.html</location>
</error-page>
<error-page>
             <error-code>500</error-code>
             <location>/500.html</location>
</error-page>

note: put the path of the error pages in <location> tab
Customizing HTML error Messages by run-time exceptions
a.    Create your own custom HTML error page 'error.html'
b.  Edit web.xml file to add the below XML snippet
e.g.
<error-page>
             <exception-type> exception.ItemNotFoundException </exception-type>
             <location>/error.html</location>
</error-page>



No comments:

Post a Comment