You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/03/22 20:47:52 UTC

DO NOT REPLY [Bug 7371] New: - error-page directive not kicking in for errors thrown from servlets

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7371>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7371

error-page directive not kicking in for errors thrown from servlets

           Summary: error-page directive not kicking in for errors thrown
                    from servlets
           Product: Tomcat 4
           Version: 4.0.2 Final
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: jmurc5@hotmail.com


===============web.xml===============
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>

 <servlet>
  <servlet-name>evil</servlet-name>
  <servlet-class>com.templar.it.fed.sd.pda.Evil</servlet-class>
 </servlet>

 <servlet-mapping>
  <servlet-name>evil</servlet-name>
  <url-pattern>/servlet/EVILSERVLET</url-pattern>
 </servlet-mapping>
 <error-page>
  <exception-type>java.lang.RuntimeException</exception-type>
  <location>/pocketpc_error.jsp</location>
 </error-page>
 
</web-app>
===============end web.xml===============

===============blah.jsp===============
<html>
<body>
<%
 if (true) throw new RuntimeException( "this sucks." );
%>
</body>
</html>
===============end blah.jsp===============

===============Evil.java===============
package com.templar.it.fed.sd.pda;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Evil extends HttpServlet
{
	
	/** Handles GET submissions. Our parameters will be coming through the 
querystring.
	 */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    {
	   if (true) throw new RuntimeException( "this is a runtime 
exception" );
	 } // end doGet
	 
} // end class
===============end Evil.jsp===============

ok...

when i go to blah.jsp, the runtime exception is caught and i get the error page 
specified in the error-page directive.

when i go to host/context/servlet/EVILSERVLET, i get tomcat's error page:
=== begin copy paste ===
Apache Tomcat/4.0.2 - HTTP Status 500 - Internal Server Error
--------------------------------------------------------------------------------
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) 
that prevented it from fulfilling this request.
exception 
java.lang.RuntimeException: this is a runtime exception
	at com.templar.it.fed.sd.pda.Evil.doGet(Evil.java:25)
(etc etc)
=== end copy paste ===

both of them do the same thing (throw RuntimeException).

i'm not sure why only the JSP directs to my error-page, and the servlet just 
gives me tomcat's stack trace.

possibilities: something to do with it being runtime ; something to do with it 
being thrown from a servlet.

either way, this has been driving me nuts for some time.

thanks

john

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>