0

I have tried to configure error page in web.xml using error-page element, but the error page is never shown rather the exceptions are thrown out in raw form to the user viewing the application.

What should I do about it? I have not found any clue as to why is this so. Any help is highly thankful.

Regards, Asif

muasif80
  • 5,586
  • 4
  • 32
  • 45

1 Answers1

4

You can add error pages for Exception as follows

 <error-page>
         <error-code>400</error-code>
         <location>/400.html</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/404.html</location>
    </error-page>

    <error-page>
        <exception-type>your.company.YourException</exception-type>
        <location>/errorPage.html</location>
    </error-page>

Recheck the Exception type if you want to show error page on all type of exception then use java.lang.Exception

jmj
  • 237,923
  • 42
  • 401
  • 438
  • Actually I was setting /ErrorPage.jsp which was giving error. But now i am using /faces/exceptionOccured.xhtml Which is not giving error. How can I access the exception object in exceptionOccured.xhtml – muasif80 May 16 '11 at 11:37
  • you can access exception from request with `javax.servlet.error.exception` key – jmj May 16 '11 at 11:44