Hello Tom Cats,

Currently under Tomcat 4.1.12 SSI "normal" configuration which invokes a
CGI script does not work. The reason for this is pretty obvious: The SSI
servelet uses the pathInfo (PATH_INFO) value and calls the request
dispatcher for any resources needed. The request dispatcher eats the
pathInfo value and the CGI servlet can't find the CGI program, because it
relies on pathInfo to tell it where the script is. Or something like that,
whatever, you cats probably know better.

Anyway, I made minor changes to three files in the current 4.1.12 distro
to solve this problem. The strategy is thus: SSI-invoked resources flag
the request with an attibute. When CGI servlet finally gets the request
dispached, he checks whether SSI servlet invoked the resource via said
attribute. If this is the case, he ignores the request.getPathInfo()
method in favor of an already-present attribute on the request which
already has the PATH_INFO environment value in it.

Voila, everything works now. Diff attached.

Nick Bauman
Software Engineer
Cortexity Development
3600 N. Dupont
Minneapolis, MN
55412
M: 612-232-7120

diff -uNr 
jakarta-tomcat-4.1.12-orig/catalina/src/share/org/apache/catalina/Globals.java 
jakarta-tomcat-4.1.12-src/catalina/src/share/org/apache/catalina/Globals.java
--- jakarta-tomcat-4.1.12-orig/catalina/src/share/org/apache/catalina/Globals.java     
 2002-09-23 03:24:20.000000000 -0600
+++ jakarta-tomcat-4.1.12-src/catalina/src/share/org/apache/catalina/Globals.java      
+ 2002-12-03 20:48:00.000000000 -0600
@@ -290,5 +290,13 @@
     public static final String WORK_DIR_ATTR =
         "javax.servlet.context.tempdir";
 
-
+       /**
+        * 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";
 }
diff -uNr 
jakarta-tomcat-4.1.12-orig/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java
 
jakarta-tomcat-4.1.12-src/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java
--- 
jakarta-tomcat-4.1.12-orig/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java
  2002-09-23 03:24:18.000000000 -0600
+++ 
+jakarta-tomcat-4.1.12-src/catalina/src/share/org/apache/catalina/servlets/CGIServlet.java
+   2002-12-03 20:54:32.000000000 -0600
@@ -966,8 +966,12 @@
             String sCGIName = null;
             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();
diff -uNr 
jakarta-tomcat-4.1.12-orig/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java 
jakarta-tomcat-4.1.12-src/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java
--- 
jakarta-tomcat-4.1.12-orig/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java  
     2002-09-23 03:24:18.000000000 -0600
+++ 
+jakarta-tomcat-4.1.12-src/catalina/src/share/org/apache/catalina/ssi/SSIServlet.java  
+      2002-12-03 19:44:06.000000000 -0600
@@ -64,38 +64,24 @@
 
 package org.apache.catalina.ssi;
 
+import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
 import java.io.PrintWriter;
-import java.io.Reader;
 import java.io.StringWriter;
-import java.io.Writer;
 import java.net.URL;
 import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Locale;
-import java.text.SimpleDateFormat;
-import java.util.StringTokenizer;
-import java.util.TimeZone;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
+
 import javax.servlet.ServletContext;
-import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletException;
 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.
  * Mapped to a path from within web.xml.
@@ -234,7 +220,7 @@
             res.setDateHeader("Expires", (
                 new java.util.Date()).getTime() + expires.longValue() * 1000);
         }
-
+        req.setAttribute(Globals.SSI_FLAG_ATTR,"true");
        processSSI( req, res, resource );
     }

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to