Setting Custom Error Page and Internet Explorer Bug

12 May

Today I came across one interesting case where in spite of doing a proper set up for custom error page in Tomcat, Internet Explorer 9.0.6 was just refusing to display my custom page.The same custom error page was  displaying fine in other browsers like Google Chrome and Firefox without any issue.But in Internet Explorer it  was showing up its own error page which was looking like below,



Now of course it does say that its 404 error,but I believe this page is somewhat not good for user experience.Users expect that we display some informative message in case if some thing goes wrong while browsing the site and that message should give them some information about error and what they need to do next and what we are doing to resolve the issue,something like below,



I was trying to do exactly the same , set up the custom error page, trigger that page by generating some error condition and check if this works in all browsers as expected.

Unfortunately  Internet Explorer seems to have  some problems displaying custom error pages in case if they are light weight in size.In addition to weight of the page, they also has certain rules which they follow while implementing custom error page,

Below is the information I copied from Eric Lawrence blog,

A common question from web developers is: What makes IE decide to show a friendly error page?

The answer is that the server’s response must meet two criteria:

  1. The HTTP Status code must be [400, 403, 404, 405, 406, 408, 409, 410, 500, 501, 505]
  2. The HTTP Response body’s byte length must be shorter than a threshold value

If the server’s response meets both criteria, then IE will show its own Friendly HTTP Error page instead of the server’s terse response.

The byte length thresholds are stored in the registry in HKEY_LOCAL_MACHINE under the subkey \SOFTWARE\Microsoft\Internet Explorer\Main\ErrorThresholds. The default threshold is 256 bytes for the response codes [403, 405, 410] and 512 bytes for response codes [400, 404, 406, 408, 409, 500, 501, 505]. If the registry entry is missing for one of the status codes, its threshold defaults to 512 bytes.

In addition to Eric’s blog, here is another KB article from Microsoft which confirms this information about the behavior of IE.

Though I feel good that we have some workaround for resolving this situation(Thanks to ASF Konstantin for showing some direction here else I would have wasted another 8 hrs trying to figure out the fix/workaround for this ), I feel its more of the bug in Internet Explorer that needs to be fixed or else they have lot of moving parts of last century in Internet Explorer 9.0.x which has not been updated since IE 5 days.

So in case if your custom error page is not getting displayed in Internet Explorer, due to below checked settings,


then probably you need to add lot of comments in your custom HTML error page so that size of custom page exceeds the threshold value.

The HTML comments are looks some like,

<!–This is a comment. Comments are not displayed in the browser–>
<!–This is a comment. Comments are not displayed in the browser–>
<!–This is a comment. Comments are not displayed in the browser–>
<!–This is a comment. Comments are not displayed in the browser–>
<!–This is a comment. Comments are not displayed in the browser–>
<!–This is a comment. Comments are not displayed in the browser–>

The reason I feel this is more of the IE bug is that job of the browser is to display whatever server sends and pass the same data to the user without playing around with the response data set.In this case, IE seems to be hiding the custom error message just because the weight of the page for that http status code is less than 512 bytes.I think this behavior of IE unnecessarily increase the size of  bytes that flows in the internet.IE has  close to 70% worldwide share in browser usage, and even 10 bytes increase in response size should be significant unnecessary overhead to network traffic.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: