Sammy Sammy - 4 months ago 43
Java Question

web.xml custom error page not working

I'm working in Eclipse+tomcat. My custom made static error page is not showing up in tomcat when i click on url for non-existing pages. generated-error.html has a simple img src="404_man.jpg" tag. But I keep getting the error page shown on the pic.

enter image description here

My servlet version is 3.0 if i view it from manifest.mf. I think it's the right document to look for Servlet version?

enter image description here
Pls don't leave me hanging...

Answer

You should add the error code or exception-type tags in web.xml for particular error...

<error-page>
    <error-code>404</error-code>
    <location>/error.jsp</location>
</error-page>
<error-page>
    <error-code>500</error-code>
    <location>/error.jsp</location>
</error-page>

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/error.jsp</location>
</error-page>