I am using Tomcat 7 and JSP pages. I would like to provide a custom error page for HTTP 500 errors.
What I did is to declare the custom error page as following in web.xml
:
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
And I created a JSP called error.jsp
with the following code:
<%@ page pageEncoding="UTF-8" isErrorPage="true" %>
<!DOCTYPE html>
<html>
<head>
<title>500</title>
</head>
<body>
<img src="${pageContext.request.contextPath}/images/500.jpg" />
</body>
</html>
Now this works in most browsers, but in Internet Explorer I am taken to the standard "The website cannot display the page" page.
Why is my custom HTTP 500 error page not being displayed in Internet Explorer?
To resolve this issue, install the most recent cumulative security update for Internet Explorer. To do this, go to Microsoft Update.
You are using an older browser in Internet Explorer. Google Chrome is newer and it also has been receiving regular updates where IE has not had many innovations (MS created Edge rather than fixing the issues in IE).
This is an IE feature. When an HTTP error page retrieved from the server is smaller than 512 bytes, then IE will by default show a "Friendly" error page like the one you're facing, which is configureable by Tools > Internet Options > Advanced > Uncheck "Show Friendly Error Message" in the browser. Other (real) browsers does not have this feature.
Making your HTTP error page a little larger than 512 bytes should workaround this IE feature. You could add some extra meta headers, add some whitespace to indent code, add some more semantic markup following your site's standard layout, add a large HTML comment, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With