tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amy...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ssi SSIServlet.java
Date Wed, 04 Dec 2002 21:09:08 GMT
amyroh      2002/12/04 13:09:08

  Modified:    catalina/src/share/org/apache/catalina Globals.java
               catalina/src/share/org/apache/catalina/servlets
                        CGIServlet.java
               catalina/src/share/org/apache/catalina/ssi SSIServlet.java
  Log:
  Fix for SSI "normal" configuration which invokes a CGI script.
  
  Patch submitted by Nick Bauman <nick@cortexity.com>.
  
  Revision  Changes    Path
  1.45      +15 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java
  
  Index: Globals.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Globals.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Globals.java	23 Sep 2002 00:16:35 -0000	1.44
  +++ Globals.java	4 Dec 2002 21:09:07 -0000	1.45
  @@ -266,6 +266,17 @@
       public static final String SESSION_PARAMETER_NAME = "jsessionid";
   
   
  +   /**
  +    * The servlet context attribute under which we store a flag used 
  +    * to mark this request as having been processed by the SSIServlet. 
  +    * We do this because of the pathInfo mangling happening when using 
  +    * the CGIServlet in conjunction with the SSI servlet. (value stored 
  +    * as an object of type String)
  +    */
  +    public static final String SSI_FLAG_ATTR = 
  +        "org.apache.catalina.ssi.SSIServlet";
  +
  +
       /**
        * The request attribute under which we forward an HTTP status code
        * (as an object of type Integer) to an error page.
  
  
  
  1.11      +13 -8     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java
  
  Index: CGIServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CGIServlet.java	22 Nov 2002 21:51:14 -0000	1.10
  +++ CGIServlet.java	4 Dec 2002 21:09:07 -0000	1.11
  @@ -967,7 +967,12 @@
               String[] sCGINames;
   
   
  -            sPathInfoOrig = this.pathInfo;
  +            if (null != req.getAttribute(Globals.SSI_FLAG_ATTR)) {
  +                // invoked by SSIServlet, which eats our req.getPathInfo() data
  +                sPathInfoOrig = (String) req.getAttribute(Globals.PATH_INFO_ATTR);
  +            } else {
  +                sPathInfoOrig = this.pathInfo;
  +            }
               sPathInfoOrig = sPathInfoOrig == null ? "" : sPathInfoOrig;
   
               sPathTranslatedOrig = req.getPathTranslated();
  
  
  
  1.2       +35 -28    jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java
  
  Index: SSIServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SSIServlet.java	26 May 2002 00:00:55 -0000	1.1
  +++ SSIServlet.java	4 Dec 2002 21:09:08 -0000	1.2
  @@ -95,6 +95,7 @@
   import javax.servlet.http.HttpServlet;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import org.apache.catalina.Globals;
   
   /**
    * Servlet to process SSI requests within a webpage.
  @@ -106,6 +107,7 @@
    * @version $Revision$, $Date$
    */
   public class SSIServlet extends HttpServlet {
  +
       /** Debug level for this servlet. */
       protected int debug = 0;
   
  @@ -217,14 +219,14 @@
                path.toUpperCase().startsWith("/META-INF") ) {
   
               res.sendError(res.SC_NOT_FOUND, path);
  -	    log( "Can't serve file: " + path );
  +        log( "Can't serve file: " + path );
               return;
           }
  -	
  -	URL resource = servletContext.getResource(path);
  +    
  +        URL resource = servletContext.getResource(path);
           if (resource==null) {
               res.sendError(res.SC_NOT_FOUND, path);
  -	    log( "Can't find file: " + path );
  +        log( "Can't find file: " + path );
               return;
           }
   
  @@ -234,37 +236,42 @@
               res.setDateHeader("Expires", (
                   new java.util.Date()).getTime() + expires.longValue() * 1000);
           }
  -
  -	processSSI( req, res, resource );
  +        
  +        req.setAttribute(Globals.SSI_FLAG_ATTR,"true");
  +        processSSI( req, res, resource );
       }
   
       protected void processSSI( HttpServletRequest req,
  -			       HttpServletResponse res,
  -			       URL resource ) throws IOException {
  -	SSIExternalResolver ssiExternalResolver = new SSIServletExternalResolver( this, req, res,
  -										  isVirtualWebappRelative,
  -										  debug );
  -	SSIProcessor ssiProcessor = new SSIProcessor( ssiExternalResolver, debug );
  +                   HttpServletResponse res,
  +                   URL resource ) throws IOException {
  +                   
  +        SSIExternalResolver ssiExternalResolver = 
  +                            new SSIServletExternalResolver( this, req, res,
  +                            isVirtualWebappRelative,
  +                            debug );
  +        SSIProcessor ssiProcessor = 
  +                            new SSIProcessor( ssiExternalResolver, debug );
   
           PrintWriter printWriter = null;
  -	StringWriter stringWriter = null;
  +        StringWriter stringWriter = null;
           if (buffered) {
  -	    stringWriter = new StringWriter();
  +            stringWriter = new StringWriter();
               printWriter = new PrintWriter( stringWriter );
           } else {
               printWriter = res.getWriter();
  -	}
  +        }
   
           URLConnection resourceInfo = resource.openConnection();
           InputStream resourceInputStream = resourceInfo.getInputStream();
  -	BufferedReader bufferedReader = new BufferedReader( new InputStreamReader( resourceInputStream
) );
  -	Date lastModifiedDate = new Date( resourceInfo.getLastModified() );
  -	ssiProcessor.process( bufferedReader, lastModifiedDate, printWriter );
  -
  -        if ( buffered ) {
  -	    printWriter.flush();
  -	    String text = stringWriter.toString();
  -            res.getWriter().write( text );
  -	}
  +        BufferedReader bufferedReader = 
  +            new BufferedReader(new InputStreamReader(resourceInputStream));
  +        Date lastModifiedDate = new Date(resourceInfo.getLastModified());
  +        ssiProcessor.process(bufferedReader, lastModifiedDate, printWriter);
  +
  +        if (buffered) {
  +            printWriter.flush();
  +            String text = stringWriter.toString();
  +            res.getWriter().write(text);
  +        }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message