Discussions

Web tier: servlets, JSP, Web frameworks: How Tomcat handles 500 Error ?

  1. How Tomcat handles 500 Error ? (2 messages)

    Hi,
    I have apache1.3.27 and Tomcat 3.3-m4 installed on my Win2000 server. I have an application deployed and everything works fine except one thing:

    If I try a URL which doesn't exist, it return me error code 500 and an internal servlet error instead of my default jsp page.

    My web.xml looks like:
    ...
      <error-page>
        <error-code>500</error-code>
        <location>/errors/defaultErrorPage.jsp</location>
      </error-page>
      
      <error-page>
        <error-code>404</error-code>
        <location>/errors/pageNotFoundPage.jsp</location>
      </error-page>
    ...
    I can see Tomcat backend console export the following message:
    ...
    request.getRequestURI=/demo/issue1
    request.getContextPath=/demo
    page not found: /content/issue1.jsp
    TemplateContentException(/content/issue1.jsp)
    PageNotFound
    ..
    Seems to me Tomcat do catch the 500 error but unable to redirect to my error jsp page.

    Is there anything else I should look at ?

    Thanks

    Threaded Messages (2)

  2. How Tomcat handles 500 Error ?[ Go to top ]

    Are you sure it is tomcat that is generating the Internal server error and not apache? I find that, depending on the connector and the configuration I amd using, 500 Errors are often generated by Apache when it can't redirect to the tomcat resource correctly
  3. How Tomcat handles 500 Error ?[ Go to top ]

    Thanks for reply.

    Yes,the error message was came from Tomcat, not Apache.
    I also put following code in web.xml trying to catch the servlet error. But seems doesn't work.
      <error-page>
        <exception-type>javax.servlet.ServletException</exception-type>
        <location>/errors/defaultErrorPage.jsp</location>
      </error-page>


    -----------------------------------------------------
    Error: 500
    Location: =/demo/issue1
    Internal Servlet Error:

    java.lang.NullPointerException
    at com.gdocomau.j2ee.web.controller.TemplateControllerServlet.processRequest(TemplateControllerServlet.java:118)
    at com.gdocomau.j2ee.web.controller.TemplateControllerServlet.doGet(TemplateControllerServlet.java:237)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:500)
    at org.apache.tomcat.core.Handler.service(Handler.java:223)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:448)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:865)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java:778)
    at org.apache.ajp.tomcat33.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:162)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:435)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:505)
    at java.lang.Thread.run(Thread.java:579)