error page in web.xml giving 404
Solution 1
What's about using WEB-INF
instead of WEB_INF
in your web.xml ?
Solution 2
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
.
Solution 3
The problem is that you are using WEB_INF instead of WEB-INF. all the resources mentioned under WEB-INF are protected from client and cannot be directly accessed so its always a good practice to move it out of the WEB-INF.
Thanks
vaibought
while(true){ do code; create algo; build architecture; project manage }
Updated on June 04, 2022Comments
-
vaibought almost 2 years
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?
-
vaibought about 13 yearsHI Roland,Thank you very much. I was duffer and was mistaking - with _. after replacing WEB_INF with WEB-INF, this works. Now I am able to see my own access denied and 404 page.