Error page in web.xml
Is it possible to use some kind of regular expression to fetch all error codes and direct them to a generic error page using the error page attribute in the web.xml file.
Instead of declaring a error page attribute fro 401, 403 ,404 errors i want ot redirect all of them to one specific page.
Is it possible to do something simular to this
<error-page>
<error-code>404</error-code>
<location>/something//file_not_found.jsp</location>
</error-page>
<error-page>
<error-code>4**</error-code>
<location>/something/error.jsp</location>
</error-page>
<error-page>
<error-code>5**</error-code>
<location>/something/error.jsp</location>
</error-page>
Sorry about the bad explanation.
In the deployment descriptor(web.xml) it is possible to specify custom error pages for Specific Exceptions or Error Codes like 500 errors or 404.
To prevent the user to see a ugly page and the hacker to get any kind of information about vunerabilities it is good custom to create custom error pages for the different codes.
What i want to do is to create one page for the 404 errir and one Generic page for the rest of the error codes that could occur.
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Time-Out
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URL Too Large
415 Unsupported Media Type
500 Server Error
501 Not Implemented
502 Bad Gateway
503 Out of Resources
504 Gateway Time-Out
505 HTTP Version not supported
And instead of creating a XML tag <error-page>
<error-code>400</error-code>
<location>/error.jsp</location>
</error-page>
for all the different codes,
(I am not even sure if all of these errors would reach as far as to my application before they were thrown. I guess a few would be sent by firewalls or the http server.)
And instead of finding that out i would just want to tell in the deployment descriptor that, here is a page that i want to display for all the error codes the application server can throw except for my 404 page.
So one thought i had was to use some kind of regular expression like
<error-page>
<error-code>4*</error-code>
<location>/error.jsp</location>
</error-page>
and then have the specific one as well
<error-page>
<error-code>404</error-code>
<location>/notfound.jsp</location>
</error-page>
This did not work(didn't allow me to deploy) and i was wondering if anybody had an idea of a simular approach i could do in the web.xml file.
I do not want to do this in the httpd.conf file of the HTTP server, since the application will be deployed on different servers.
Hope anybody has a solution. It is quick to add all the error codes, but i would think there is a shorter and "prettier" way of doing it.