How does server prioritize which type of web.xml error page to use?

This is not specific to Tomcat. This is specific to the Servlet API. How the error page is determined is specified in chapter 9.9.2 of Servlet API specification 2.5. Here’s an extract of relevance: SRV.9.9.2 Error Pages If no error-page declaration containing an exception-type fits using the class-hierarchy match, and the exception thrown is a … Read more

Apache’s ErrorDocument directive does not redirect

A few different mis-conceptions in the question. The following PHP code: header(“HTTP/1.0 500 Internal Server Error”); die(); Will never trigger an Apache error page – it’s triggering your browser’s default error page. Once control has been given over to PHP, it does not go back to Apache for error handling. ErrorDocument only works for error … Read more

How to show user-friendly error page in browser when runtime exception is thrown by servlet?

Just declare an <error-page> in web.xml wherein you can specify the page which should be displayed on a certain Throwable (or any of its subclasses) or a HTTP status code. E.g. <error-page> <exception-type>java.lang.Exception</exception-type> <location>/error.jsp</location> </error-page> which will display the error page on any subclass of the java.lang.Exception, but thus not java.lang.Throwable or java.lang.Error. This way … Read more

Rewrite URL after redirecting 404 error htaccess

Try this in your .htaccess: .htaccess ErrorDocument 404 http://example.com/404/ ErrorDocument 500 http://example.com/500/ # or map them to one error document: # ErrorDocument 404 /pages/errors/error_redirect.php # ErrorDocument 500 /pages/errors/error_redirect.php RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/404/$ RewriteRule ^(.*)$ /pages/errors/404.php [L] RewriteCond %{REQUEST_URI} ^/500/$ RewriteRule ^(.*)$ /pages/errors/500.php [L] # or map them to one error document: #RewriteCond … Read more

Routing for custom ASP.NET MVC 404 Error page

I’ve tried to enable custom errors on production server for 3 hours, seems I found final solution how to do this in ASP.NET MVC without any routes. To enable custom errors in ASP.NET MVC application we need (IIS 7+): Configure custom pages in web config under system.web section: <customErrors mode=”RemoteOnly” defaultRedirect=”~/error”> <error statusCode=”404″ redirect=”~/error/Error404″ /> … Read more

ASP.NET custom error page – Server.GetLastError() is null

Looking more closely at my web.config set up, one of the comments in this post is very helpful in asp.net 3.5 sp1 there is a new parameter redirectMode So we can amend customErrors to add this parameter: <customErrors mode=”RemoteOnly” defaultRedirect=”~/errors/GeneralError.aspx” redirectMode=”ResponseRewrite” /> the ResponseRewrite mode allows us to load the «Error Page» without redirecting the … Read more

How to specify the default error page in web.xml?

On Servlet 3.0 or newer you could just specify <web-app …> <error-page> <location>/general-error.html</location> </error-page> </web-app> But as you’re still on Servlet 2.5, there’s no other way than specifying every common HTTP error individually. You need to figure which HTTP errors the enduser could possibly face. On a barebones webapp with for example the usage of … Read more