Paritosh Pandey
Paritosh Pandey

Reputation: 23

Apache tomcat <error-page> tag in conf/web.xml not rendering an error page

In /conf/web.xml I've mentioned an tag as follows:

 <error-page>
    <exception-type>401</exception-type>
    <location>/error.jsp</location>
</error-page>
<error-page>
    <exception-type>403</exception-type>
    <location>/error.jsp</location>
</error-page>
<error-page>
    <exception-type>404</exception-type>
    <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>

before this I also mentioned just

<error-page>
    <exception-type>404</exception-type>
    <location>/error.jsp</location>
</error-page>

but it's still rendering the same default page of tomcat instead of the custom "error.jsp" page. I'm stuck in the problem since last 13 hours.

Upvotes: 1

Views: 2610

Answers (1)

swayamraina
swayamraina

Reputation: 3158

Try using error-code instead of exception-type

<error-page>
    <error-code>403</error-code>
    <location>/error.jsp</location>
</error-page>

Upvotes: 2

Related Questions