Archive for September, 2012

404 error page

Posted: 3 September 2012 in Uncategorized

I was playing about with the error page configuration of my web app. I configured the app to intercept page not found errors and display a nice page instead of the default response from Tomcat.

<error-page>
<error-code>404</error-code>
<location>/?view=error_404</location>
</error-page>

I was bemused when it wouldn’t intercept the error.
It turns out that setting the status code to 404 on the response is not the same as sending a 404 error.

response.setStatus(404); /* does not get intercepted */
response.sendError(404); /* gets intercepted */

another little mistery explained. 😀