This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I don't want tomcat to come up with its standard error page when a non-200 status code is returned. Is this done by using the <error-code> tag in web.xml?
If this is the solution, is there a way to specify an error page base on a range of status codes? It is difficult to foresee all the possible error status code that might be returned by tomcat and I can't list all of them in my web.xml.
But this really calls for a framework, or at least an exception class hierarchy if you want to make effective use of it, and you might be better off handling errors in a way that is more consistent with your application's organization/workflow, without relying on the servlet-providing mechanism.
<a href="http://webjavenue.com/" target="_blank" rel="nofollow">Your first website in Java: easier than you think</a>
Joined: Jan 28, 2004
"If a servlet generates an error that is not handled by the error page mechanism as described above, the container must ensure to send a response with status 500."
To me, this sounds like if you make sure you have an error page defined for status code 500, it will work as a safety net capturing everything that misses all other error page definitions.
No, this doesn't catch everything. There are some error pages that are generated by tomcat, 2 examples are:
HTTP Status 408 - The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser
HTTP Status 400 - Invalid direct reference to form login page
The first one happens if you wait too long in your login form. The second one happens if you directly access the login page. Both errors are [B]generated by tomcat[/B}, not by servlet. I can define error pages for this 2 error codes, but what if there are some other error codes that tomcat may generate. I can't foresee all of them.
Joined: Feb 15, 2006
> No, this doesn't catch everything. There are some error pages that are generated by tomcat
Despite your having a 500 error page specified in web.xml? Well, too bad they do not abide by the spec.
Whatever the case, there is still no syntax to define an error page per a range of status code values. I wish we lived in an ideal world...