title: Tomcat: Custom error page not working
body: <p>Well this should've been simple enough. I modified the project's web.xml in order to display my own error page for 500's:</p>
  
  <pre><code>&lt;error-page&gt;
      &lt;error-code&gt;500&lt;/error-code&gt;
      &lt;location&gt;/error.jsp&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>
  
  <p>Then I wrote the simplest servlet in order to test it:</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
  }
  </code></pre>
  
  <p>The custom page (which is located at the root directory) is then completely ignored and I get the default Tomcat error page instead.</p>
  
  <p>I'm using the Tomcat 6 version that comes with the debugger of MyEclipse. I've tripled-checked this for typos, but I can't find anything unusual. I'm wondering whether the <em>error-page</em> tag needs to be in a certain part of the document. Does anyone know what could be going wrong?</p>
  
  <p>*Edit:
  This is the full web.xml that was requested:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" 
  
      xmlns="http://java.sun.com/xml/ns/javaee" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
  
  &lt;display-name&gt;&lt;/display-name&gt;
  
  &lt;jsp-config&gt; 
     &lt;jsp-property-group&gt; 
        &lt;url-pattern&gt;/js/base.js&lt;/url-pattern&gt;
        &lt;url-pattern&gt;/js/catalog.base.js&lt;/url-pattern&gt;
        &lt;url-pattern&gt;/js/minicatalog.base.js&lt;/url-pattern&gt;
        &lt;url-pattern&gt;/js/addresses.js&lt;/url-pattern&gt;
     &lt;/jsp-property-group&gt; 
  &lt;/jsp-config&gt;
  
  &lt;mime-mapping&gt;
      &lt;extension&gt;pdf&lt;/extension&gt;
      &lt;mime-type&gt;application/pdf&lt;/mime-type&gt;
  &lt;/mime-mapping&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;classpath:/applicationContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- error-page&gt;
      &lt;error-code&gt;403&lt;/error-code&gt;
      &lt;location&gt;/index.jsp?redirect=1&lt;/location&gt;
  &lt;/error-page--&gt;
  
  &lt;error-page&gt;
      &lt;error-code&gt;500&lt;/error-code&gt;
      &lt;location&gt;/error.jsp&lt;/location&gt;
  &lt;/error-page&gt;
  
  &lt;!-- BASE --&gt;
  &lt;servlet&gt;
      &lt;description&gt;User entity methods.&lt;/description&gt;
      &lt;display-name&gt;User&lt;/display-name&gt;
      &lt;servlet-name&gt;UserServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.base.servlet.UserServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;UserServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/UserServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;Person entity methods.&lt;/description&gt;
      &lt;display-name&gt;Person&lt;/display-name&gt;
      &lt;servlet-name&gt;PersonServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.base.servlet.PersonServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;PersonServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/PersonServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;Company entity methods.&lt;/description&gt;
      &lt;display-name&gt;Company&lt;/display-name&gt;
      &lt;servlet-name&gt;CompanyServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.base.servlet.CompanyServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;CompanyServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/CompanyServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;Module entity methods.&lt;/description&gt;
      &lt;display-name&gt;Module&lt;/display-name&gt;
      &lt;servlet-name&gt;ModuleServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.base.servlet.ModuleServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;ModuleServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/ModuleServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;Profile entity methods.&lt;/description&gt;
      &lt;display-name&gt;Profile&lt;/display-name&gt;
      &lt;servlet-name&gt;ProfileServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.base.servlet.ProfileServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;ProfileServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/ProfileServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;Address entity methods.&lt;/description&gt;
      &lt;display-name&gt;Address&lt;/display-name&gt;
      &lt;servlet-name&gt;AddressServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.base.servlet.AddressServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;AddressServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/AddressServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;!-- END BASE --&gt;
  
  &lt;!-- PUSH --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;icepush&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.icepush.servlet.ICEpushServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;icepush&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.icepush&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;!-- END PUSH --&gt;
  
  &lt;!-- TRUCKS --&gt;
  &lt;servlet&gt;
      &lt;description&gt;Employee entity methods.&lt;/description&gt;
      &lt;display-name&gt;Employee&lt;/display-name&gt;
      &lt;servlet-name&gt;EmployeeServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.trucks.servlet.EmployeeServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;EmployeeServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/EmployeeServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;Vehicle entity methods.&lt;/description&gt;
      &lt;display-name&gt;Vehicle&lt;/display-name&gt;
      &lt;servlet-name&gt;VehicleServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.trucks.servlet.VehicleServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;VehicleServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/VehicleServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;VehicleBrand entity methods.&lt;/description&gt;
      &lt;display-name&gt;VehicleBrand&lt;/display-name&gt;
      &lt;servlet-name&gt;VehicleBrandServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.trucks.servlet.VehicleBrandServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;VehicleBrandServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/VehicleBrandServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;Report methods.&lt;/description&gt;
      &lt;display-name&gt;Report&lt;/display-name&gt;
      &lt;servlet-name&gt;ReportServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.trucks.servlet.ReportServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;ReportServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/ReportServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;ExpenseLog methods.&lt;/description&gt;
      &lt;display-name&gt;ExpenseLog&lt;/display-name&gt;
      &lt;servlet-name&gt;ExpenseLogServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.trucks.servlet.ExpenseLogServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;ExpenseLogServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/ExpenseLogServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;IncomeLog methods.&lt;/description&gt;
      &lt;display-name&gt;IncomeLog&lt;/display-name&gt;
      &lt;servlet-name&gt;IncomeLogServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.trucks.servlet.IncomeLogServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;IncomeLogServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/IncomeLogServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;description&gt;FileExport methods.&lt;/description&gt;
      &lt;display-name&gt;FileExport&lt;/display-name&gt;
      &lt;servlet-name&gt;FileExportServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sitei.trucks.servlet.FileExportServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;FileExportServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/servlet/FileExportServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;!-- END TRUCKS --&gt;
  
  &lt;session-config&gt;
    &lt;session-timeout&gt;15&lt;/session-timeout&gt; 
  &lt;/session-config&gt;
  
  &lt;!--security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;LOGIN&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;user-data-constraint&gt;
          &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;
      &lt;/user-data-constraint&gt;
  &lt;/security-constraint--&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  </code></pre>
  
  <p></p>