Not able to configure Error Page?

Customers have often reported issues that they are not able to configure error page even though the do the configuration in the web.xml correctly

web.xml
<?xml version=’1.0′ encoding=’UTF-8′?>
<web-app xmlns=”http://java.sun.com/xml/ns/j2ee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
<display-name>TestApplication</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/error.jsp</location>
</error-page>
</web-app>

error.jsp

<%@page isErrorPage=”true” contentType=”text/html” %>
<html>
<body>
Request that failed: ${pageContext.errorData.requestURI}
<br />
Status code: ${pageContext.errorData.statusCode}
<br />
Exception: ${pageContext.errorData.throwable}
<br />
${pageContext.errorData.servletName}
</body>
</html>
index.jsp
<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
<%
String s = null;
out.println(s.trim());
%>
</BODY>
</HTML>

When I deployed this application on Weblogic Server and tried to acces the application. I got null pointer exception causing server to send HTTP 500 Response
with Exception

java.lang.NullPointerException
at jsp_servlet.__index._jspService(__index.java:76)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:292)
Truncated. see log file for complete stacktrace

But since we had done the error page configuration, we expected to see our custom error page. This was not the case.
We saw the following. ( Note I was using IE 7)



I had to do the following configuration change on IE to get it working. ( Uncheck Show Friendly HTTP Error Messages)



After changing the IE Setting, I was able to get the custom error page.


Reference :-

http://www.java2s.com

Latest Comments

  1. Ravi Kumar February 4, 2011
    • Administrator February 7, 2011
  2. Sheeba November 26, 2014
    • Administrator December 1, 2014

Leave a Reply