Author: remy.maucherat(a)jboss.com
Date: 2007-11-16 16:42:44 -0500 (Fri, 16 Nov 2007)
New Revision: 350
Modified:
trunk/java/org/apache/catalina/servlets/CGIServlet.java
trunk/java/org/apache/jasper/compiler/Generator.java
trunk/webapps/docs/changelog.xml
Log:
- Port CGI inclusion fix.
- Port generation of shorter inner classes.
Modified: trunk/java/org/apache/catalina/servlets/CGIServlet.java
===================================================================
--- trunk/java/org/apache/catalina/servlets/CGIServlet.java 2007-11-16 17:20:12 UTC (rev
349)
+++ trunk/java/org/apache/catalina/servlets/CGIServlet.java 2007-11-16 21:42:44 UTC (rev
350)
@@ -235,7 +235,7 @@
*
* @author Martin T Dengler [root(a)martindengler.com]
* @author Amy Roh
- * @version $Revision: 505743 $, $Date: 2007-02-10 19:55:08 +0100 (sam., 10 févr. 2007)
$
+ * @version $Revision: 595801 $, $Date: 2007-11-16 21:07:07 +0100 (Fri, 16 Nov 2007) $
* @since Tomcat 4.0
*
*/
@@ -267,7 +267,7 @@
static Object expandFileLock = new Object();
/** the shell environment variables to be passed to the CGI script */
- static Hashtable shellEnv = new Hashtable();
+ static Hashtable<String,String> shellEnv = new
Hashtable<String,String>();
/**
* Sets instance variables.
@@ -644,8 +644,8 @@
* See <a
href="http://www.rgagnon.com/javadetails/java-0150.html">Read environment
* variables from an application</a> for original source and article.
*/
- private Hashtable getShellEnvironment() throws IOException {
- Hashtable envVars = new Hashtable();
+ private Hashtable<String,String> getShellEnvironment() throws IOException {
+ Hashtable<String,String> envVars = new Hashtable<String,String>();
Process p = null;
Runtime r = Runtime.getRuntime();
String OS = System.getProperty("os.name").toLowerCase();
@@ -694,7 +694,7 @@
* <p>
* </p>
*
- * @version $Revision: 505743 $, $Date: 2007-02-10 19:55:08 +0100 (sam., 10 févr.
2007) $
+ * @version $Revision: 595801 $, $Date: 2007-11-16 21:07:07 +0100 (Fri, 16 Nov 2007)
$
* @since Tomcat 4.0
*
*/
@@ -729,7 +729,7 @@
private File workingDirectory = null;
/** cgi command's command line parameters */
- private ArrayList cmdLineParameters = new ArrayList();
+ private ArrayList<String> cmdLineParameters = new
ArrayList<String>();
/** whether or not this object is valid or not */
private boolean valid = false;
@@ -784,16 +784,31 @@
*/
protected void setupFromRequest(HttpServletRequest req)
throws UnsupportedEncodingException {
-
- this.contextPath = req.getContextPath();
- this.servletPath = req.getServletPath();
- this.pathInfo = req.getPathInfo();
+
+ boolean isIncluded = false;
+
+ // Look to see if this request is an include
+ if (req.getAttribute(Globals.INCLUDE_REQUEST_URI_ATTR) != null) {
+ isIncluded = true;
+ }
+ if (isIncluded) {
+ this.contextPath = (String) req.getAttribute(
+ Globals.INCLUDE_CONTEXT_PATH_ATTR);
+ this.servletPath = (String) req.getAttribute(
+ Globals.INCLUDE_SERVLET_PATH_ATTR);
+ this.pathInfo = (String) req.getAttribute(
+ Globals.INCLUDE_PATH_INFO_ATTR);
+ } else {
+ this.contextPath = req.getContextPath();
+ this.servletPath = req.getServletPath();
+ this.pathInfo = req.getPathInfo();
+ }
// If getPathInfo() returns null, must be using extension mapping
// In this case, pathInfo should be same as servletPath
if (this.pathInfo == null) {
this.pathInfo = this.servletPath;
}
-
+
// If the request method is GET, POST or HEAD and the query string
// does not contain an unencoded "=" this is an indexed query.
// The parsed query string becomes the command line parameters
@@ -801,7 +816,13 @@
if (req.getMethod().equals("GET")
|| req.getMethod().equals("POST")
|| req.getMethod().equals("HEAD")) {
- String qs = req.getQueryString();
+ String qs;
+ if (isIncluded) {
+ qs = (String) req.getAttribute(
+ Globals.INCLUDE_QUERY_STRING_ATTR);
+ } else {
+ qs = req.getQueryString();
+ }
if (qs != null && qs.indexOf("=") == -1) {
StringTokenizer qsTokens = new StringTokenizer(qs, "+");
while ( qsTokens.hasMoreTokens() ) {
@@ -961,7 +982,7 @@
* (apologies to Marv Albert regarding MJ)
*/
- Hashtable envp = new Hashtable();
+ Hashtable<String,String> envp = new Hashtable<String,String>();
// Add the shell environment variables (if any)
envp.putAll(shellEnv);
@@ -1415,7 +1436,7 @@
* and <code>setResponse</code> methods, respectively.
* </p>
*
- * @version $Revision: 505743 $, $Date: 2007-02-10 19:55:08 +0100 (sam., 10 févr.
2007) $
+ * @version $Revision: 595801 $, $Date: 2007-11-16 21:07:07 +0100 (Fri, 16 Nov
2007) $
*/
protected class CGIRunner {
@@ -1539,7 +1560,7 @@
*/
protected String[] hashToStringArray(Hashtable h)
throws NullPointerException {
- Vector v = new Vector();
+ Vector<String> v = new Vector<String>();
Enumeration e = h.keys();
while (e.hasMoreElements()) {
String k = e.nextElement().toString();
Modified: trunk/java/org/apache/jasper/compiler/Generator.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Generator.java 2007-11-16 17:20:12 UTC (rev
349)
+++ trunk/java/org/apache/jasper/compiler/Generator.java 2007-11-16 21:42:44 UTC (rev
350)
@@ -3310,9 +3310,7 @@
charArrayBuffer = null;
err = compiler.getErrorDispatcher();
ctxt = compiler.getCompilationContext();
- fragmentHelperClass = new FragmentHelperClass(ctxt
- .getServletClassName()
- + "Helper");
+ fragmentHelperClass = new FragmentHelperClass("Helper");
pageInfo = compiler.getPageInfo();
/*
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2007-11-16 17:20:12 UTC (rev 349)
+++ trunk/webapps/docs/changelog.xml 2007-11-16 21:42:44 UTC (rev 350)
@@ -68,6 +68,9 @@
<fix>
More extensible SSO. (remm)
</fix>
+ <fix>
+ Fix a bug that causes CGI Servlet to fail when it is included. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
@@ -89,6 +92,9 @@
<fix>
Remove log field for XML handlers. (remm)
</fix>
+ <fix>
+ <bug>43702</bug>: Inner class files have unnecessarily long names.
(markt)
+ </fix>
</changelog>
</subsection>
</section>