tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/resources LocalStrings.properties
Date Thu, 09 Nov 2000 21:18:10 GMT
craigmcc    00/11/09 13:18:10

  Modified:    src/share/org/apache/tomcat/facade Tag: tomcat_32
                        RequestDispatcherImpl.java
               src/share/org/apache/tomcat/resources Tag: tomcat_32
                        LocalStrings.properties
  Log:
  Previous changes implemented "exception rethrowing" in the case of a path
  based include().  This patch adds the following enhancements:
  
  - If an included servlet throws an exception other than IOException or
    ServletException, wrap it in a new ServletException (as the root cause)
    and throw that instead.
  
  - Add exception throwing support in the following additional cases:
    * Path based forward() - getServletContext().getRequestDispatcher()
    * Name based include() - getServletContext().getNamedDispatcher()
    * Name based forward() - getServletContext().getNamedDispatcher()
  
  - When processing a named based include, set the "included" flag on the
    response so that attempts to modify headers and cookies in the included
    servlet are (correctly) ignored.
  
  Currently passes all the Watchdog servlet tests, and all the Watchdog JSP
  tests except for some taglib-related ones that are unrelated to this
  particular issue.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.5   +97 -8     jakarta-tomcat/src/share/org/apache/tomcat/facade/Attic/RequestDispatcherImpl.java
  
  Index: RequestDispatcherImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/facade/Attic/RequestDispatcherImpl.java,v
  retrieving revision 1.8.2.4
  retrieving revision 1.8.2.5
  diff -u -r1.8.2.4 -r1.8.2.5
  --- RequestDispatcherImpl.java	2000/11/09 13:27:36	1.8.2.4
  +++ RequestDispatcherImpl.java	2000/11/09 21:18:09	1.8.2.5
  @@ -188,7 +188,28 @@
   
   	// CM should have set the wrapper - call it
   	ServletWrapper wr=realRequest.getWrapper();
  -	if( wr!=null ) wr.service(realRequest, realResponse);
  +        Throwable t = null;
  +        if( wr != null ) {
  +            try {
  +                wr.service(realRequest, realResponse);
  +            } catch (Throwable t1) {
  +                t = t1;
  +            }
  +        }
  +
  +        // Clean up the request and response as needed
  +        ;       // No action required
  +
  +        // Rethrow any exception thrown by the forwarded-to servlet
  +        if (t != null) {
  +            if (t instanceof IOException)
  +                throw (IOException) t;
  +            else if (t instanceof ServletException)
  +                throw (ServletException) t;
  +            else
  +                throw new ServletException
  +                    (sm.getString("dispatcher.forwardException", t));
  +        }
   
   	// close the response - output after this point will be discarded.
   	realResponse.finish();
  @@ -348,12 +369,17 @@
   	    realResponse.setIncluded( false );
   	}
   
  +        // Rethrow any exception thrown by the included servlet
   	if (t != null) {
   	    if (t instanceof IOException)
   		throw (IOException) t;
   	    else if (t instanceof ServletException)
   		throw (ServletException) t;
  +            else
  +                throw new ServletException
  +                    (sm.getString("dispatcher.includeException", t));
   	}
  +
       }
   
   	
  @@ -364,13 +390,48 @@
       public void includeNamed(ServletRequest request, ServletResponse response)
   	throws ServletException, IOException
       {
  -	// Use the original request - as in specification !
   
   	// We got here if name!=null, so assert it
   	ServletWrapper wrapper = context.getServletByName( name );
  -	Request realR=((HttpServletRequestFacade)request).getRealRequest();
  -	if( wrapper!=null)
  -	    wrapper.service( realR, realR.getResponse());
  +
  +	// Use the original request - as in specification !
  +        Request realRequest = ((HttpServletRequestFacade)request).
  +	    getRealRequest();
  +	Response realResponse = realRequest.getResponse();
  +
  +        // Set the "included" flag so that things like header setting in the
  +        // included servlet will be correctly ignored
  +	boolean old_included=realResponse.isIncluded();
  +	if( ! old_included ) {
  +	    realResponse.setIncluded( true );
  +	}
  +
  +        // Call the included servlet
  +        Throwable t = null;
  +	if( wrapper!=null) {
  +            try {
  +                wrapper.service( realRequest, realRequest.getResponse());
  +            } catch (Throwable t1) {
  +                t = t1;
  +            }
  +        }
  +
  +        // Clean up the request and response as needed
  +	if( ! old_included ) {
  +	    realResponse.setIncluded( false );
  +	}
  +
  +        // Rethrow any exception thrown by the included servlet
  +	if (t != null) {
  +	    if (t instanceof IOException)
  +		throw (IOException) t;
  +	    else if (t instanceof ServletException)
  +		throw (ServletException) t;
  +            else
  +                throw new ServletException
  +                    (sm.getString("dispatcher.includeException", t));
  +	}
  +
       }
   
       /** Named forward
  @@ -378,11 +439,39 @@
       public void forwardNamed(ServletRequest request, ServletResponse response)
   	throws ServletException, IOException
       {
  +
  +	// We got here if name!=null, so assert it
   	ServletWrapper wrapper = context.getServletByName( name );
  -	Request realR=((HttpServletRequestFacade)request).getRealRequest();
  +
  +	// Use the original request - as in specification !
  +        Request realRequest = ((HttpServletRequestFacade)request).
  +	    getRealRequest();
  +	Response realResponse = realRequest.getResponse();
  +
  +        // Call the forwarded-to servlet
  +        Throwable t = null;
  +	if( wrapper!=null) {
  +            try {
  +                wrapper.service( realRequest, realRequest.getResponse());
  +            } catch (Throwable t1) {
  +                t = t1;
  +            }
  +        }
  +
  +        // Clean up the request and response as needed
  +        ;       // No action required
  +
  +        // Rethrow any exception thrown by the forwarded-to servlet
  +	if (t != null) {
  +	    if (t instanceof IOException)
  +		throw (IOException) t;
  +	    else if (t instanceof ServletException)
  +		throw (ServletException) t;
  +            else
  +                throw new ServletException
  +                    (sm.getString("dispatcher.forwardException", t));
  +	}
   
  -	if( wrapper!=null)
  -	    wrapper.service( realR, realR.getResponse());
       }    
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.3   +5 -1      jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/resources/LocalStrings.properties,v
  retrieving revision 1.4.2.2
  retrieving revision 1.4.2.3
  diff -u -r1.4.2.2 -r1.4.2.3
  --- LocalStrings.properties	2000/09/28 02:07:06	1.4.2.2
  +++ LocalStrings.properties	2000/11/09 21:18:09	1.4.2.3
  @@ -1,4 +1,4 @@
  -# $Id: LocalStrings.properties,v 1.4.2.2 2000/09/28 02:07:06 larryi Exp $
  +# $Id: LocalStrings.properties,v 1.4.2.3 2000/11/09 21:18:09 craigmcc Exp $
   #
   
   # Localized strings for package org.apache.tomcat.core
  @@ -21,6 +21,10 @@
   defaulterrorpage.thisdocumenthasmoved=This document has moved
   defaulterrorpage.internalservleterror=Internal Servlet Error:
   defaulterrorpage.notfoundrequest=Not found request:
  +
  +#RequestDispatcherImpl.java
  +dispatcher.forwardException=Forwarded servlet threw exception
  +dispatcher.includeException=Included servlet threw exception
   
   #Tomcat.java
   tomcat.usage=usage: 
  
  
  

Mime
View raw message