Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error page in web.xml giving 404

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?

like image 772
vaibought Avatar asked Dec 05 '22 22:12

vaibought


2 Answers

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.

like image 86
Axel Knauf Avatar answered Dec 19 '22 22:12

Axel Knauf


What's about using WEB-INF instead of WEB_INF in your web.xml ?

like image 35
Roland Huß Avatar answered Dec 19 '22 23:12

Roland Huß