In one of my project, I need to handle the 404(Resource not found) and 403(Access Denied). I am giving the configuration in web.xml as
<error-page>
<error-code>404</error-code>
<location>/WEB_INF/jsp/web/exception/weberror.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/WEB_INF/jsp/web/exception/accessDenied.jsp</location>
</error-page>
</error-page>
Now when the access denied generates, browser is showing me native 404. I also remove the friendly error page setting in browser but on removing that I am getting a blank page.
My jsps are in WEB-INF folder. The path where all jsps are places is
/WEB_INF/jsp/
Please help me out. If I am missing something?
Files under /WEB-INF/
are protected from direct access by the client, this is defined in the Java EE specification. So your error pages will have to reside outside this directory. Try moving them to a dedicated location, e. g. /errors/404.jsp
.
What's about using WEB-INF
instead of WEB_INF
in your web.xml ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With