Guys I am struggling with the problem of opening my custom error page in Tomcat in Windows Environment. Some of solution I got but no luck. I tried almost all links but its
The same can be implemented programmatically if you use embedded Tomcat for example like this:
Context appContext = ...
ErrorPage errorPage = new ErrorPage();
errorPage.setErrorCode(HttpServletResponse.SC_NOT_FOUND);
errorPage.setLocation("/my_custom_error_page.html");
appContext.addErrorPage(er);
Try putting the following snippet in your WEB-INF/web.xml
<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>
In this case Error.jsp
is at the same level as WEB-INF
directory (not inside it).