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/core RequestDispatcherImpl.java
Date Mon, 03 Apr 2000 19:33:56 GMT
craigmcc    00/04/03 12:33:55

  Modified:    src/share/org/apache/tomcat/core RequestDispatcherImpl.java
  Log:
  Corrected the "merging" of query parameters when processing an include()
  or forward() request.  Previously, any parameters included on the uri used
  to create the RequestDispatcher were *replacing* the original parameters
  with the same names, rather than being *merged* with them.
  
  The submitted bug report used <jsp:include> to illustrate the problem, but
  the underlying cause was inside RequestDispatcherImpl and therefore
  affected servlets as well as JSP pages.
  
  Please (Costin, especially) review this change for side effects -- it's a
  pretty important spec compliance issue.
  
  PR: 150
  Submitted by:	ayiu@us.oracle.com
  
  Revision  Changes    Path
  1.21      +39 -1     jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java
  
  Index: RequestDispatcherImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/RequestDispatcherImpl.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- RequestDispatcherImpl.java	2000/03/29 19:22:38	1.20
  +++ RequestDispatcherImpl.java	2000/04/03 19:33:55	1.21
  @@ -330,7 +330,45 @@
   	Enumeration e=newParams.keys();
   	while(e.hasMoreElements() ) {
   	    String key=(String)e.nextElement();
  -	    parameters.put( key, newParams.get(key));
  +	    Object oldValue = parameters.get(key);
  +	    Object newValue = newParams.get(key);
  +	    // The simple case -- no existing parameters with this name
  +	    if (oldValue == null) {
  +		parameters.put( key, newValue);
  +		continue;
  +	    }
  +	    // Construct arrays of the old and new values
  +	    String oldValues[] = null;
  +	    if (oldValue instanceof String[]) {
  +		oldValues = (String[]) oldValue;
  +	    } else if (oldValue instanceof String) {
  +		oldValues = new String[1];
  +		oldValues[0] = (String) oldValue;
  +	    } else {
  +		// Can not happen?
  +		oldValues = new String[1];
  +		oldValues[0] = oldValue.toString();
  +	    }
  +	    String newValues[] = null;
  +	    if (newValue instanceof String[]) {
  +		newValues = (String[]) newValue;
  +	    } else if (newValue instanceof String) {
  +		newValues = new String[1];
  +		newValues[0] = (String) newValue;
  +	    } else {
  +		// Can not happen?
  +		newValues = new String[1];
  +		newValues[0] = newValue.toString();
  +	    }
  +	    // Merge the two sets of values into a new array
  +	    String mergedValues[] =
  +		new String[newValues.length + oldValues.length];
  +	    for (int i = 0; i < newValues.length; i++)
  +		mergedValues[i] = newValues[i];	// New values first per spec
  +	    for (int i = newValues.length; i < mergedValues.length; i++)
  +		mergedValues[i] = oldValues[i - newValues.length];
  +	    // Save the merged values list in the original request
  +	    parameters.put(key, mergedValues);
   	}
       }
   
  
  
  

Mime
View raw message