luehe 2003/02/12 09:39:11 Modified: catalina/src/share/org/apache/catalina/core ApplicationDispatcher.java ApplicationHttpRequest.java Log: According to SRV.4.1.1 ("When Parameters Are Available"), post form data must be available to the servlet via the request object's input stream until the first call to a method of the "getParameter" family. Post form data used to be consumed from the input stream and added to the parameter set *before* any such method call. It is now read from the input stream as part of the method call. Revision Changes Path 1.9 +5 -9 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java Index: ApplicationDispatcher.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ApplicationDispatcher.java 29 Jan 2003 01:42:38 -0000 1.8 +++ ApplicationDispatcher.java 12 Feb 2003 17:39:11 -0000 1.9 @@ -466,11 +466,7 @@ if (queryString != null) { wrequest.setAttribute(Globals.FORWARD_QUERY_STRING_ATTR, queryString); - } - - if (queryString != null) { wrequest.setQueryString(queryString); - wrequest.mergeParameters(queryString); } // only set the Dispatcher Type to Forward if it has not been set. It will have @@ -631,7 +627,7 @@ if (queryString != null) { wrequest.setAttribute(Globals.INCLUDE_QUERY_STRING_ATTR, queryString); - wrequest.mergeParameters(queryString); + wrequest.setQueryString(queryString); } wrequest.setAttribute(ApplicationFilterFactory.DISPATCHER_TYPE_ATTR, 1.3 +74 -51 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationHttpRequest.java Index: ApplicationHttpRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationHttpRequest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ApplicationHttpRequest.java 17 Dec 2002 20:06:20 -0000 1.2 +++ ApplicationHttpRequest.java 12 Feb 2003 17:39:11 -0000 1.3 @@ -190,6 +190,12 @@ StringManager.getManager(Constants.Package); + /** + * Have the parameters for this request already been parsed? + */ + private boolean parsedParams = false; + + // ------------------------------------------------- ServletRequest Methods @@ -276,6 +282,7 @@ */ public String getParameter(String name) { + parseParameters(); synchronized (parameters) { Object value = parameters.get(name); if (value == null) @@ -297,6 +304,7 @@ */ public Map getParameterMap() { + parseParameters(); return (parameters); } @@ -308,6 +316,7 @@ */ public Enumeration getParameterNames() { + parseParameters(); synchronized (parameters) { return (new Enumerator(parameters.keySet())); } @@ -323,6 +332,7 @@ */ public String[] getParameterValues(String name) { + parseParameters(); synchronized (parameters) { Object value = parameters.get(name); if (value == null) @@ -389,7 +399,6 @@ // -------------------------------------------------------- Package Methods - /** * Return descriptive information about this implementation. */ @@ -423,47 +432,6 @@ /** - * Merge the parameters from the specified query string (if any), and - * the parameters already present on this request (if any), such that - * the parameter values from the query string show up first if there are - * duplicate parameter names. - * - * @param queryString The query string containing parameters to be merged - */ - void mergeParameters(String queryString) { - - if ((queryString == null) || (queryString.length() < 1)) - return; - - HashMap queryParameters = new HashMap(); - String encoding = getCharacterEncoding(); - if (encoding == null) - encoding = "ISO-8859-1"; - try { - RequestUtil.parseParameters - (queryParameters, queryString, encoding); - } catch (Exception e) { - ; - } - synchronized (parameters) { - Iterator keys = parameters.keySet().iterator(); - while (keys.hasNext()) { - String key = (String) keys.next(); - Object value = queryParameters.get(key); - if (value == null) { - queryParameters.put(key, parameters.get(key)); - continue; - } - queryParameters.put - (key, mergeValues(value, parameters.get(key))); - } - parameters = queryParameters; - } - - } - - - /** * Set the context path for this request. * * @param contextPath The new context path @@ -522,11 +490,6 @@ } } - // Initialize the parameters for this request - synchronized (parameters) { - parameters = copyMap(request.getParameterMap()); - } - // Initialize the path elements for this request contextPath = request.getContextPath(); pathInfo = request.getPathInfo(); @@ -561,6 +524,26 @@ } + /** + * Parses the parameters of this request. + * + * If parameters are present in both the query string and the request + * content, they are merged. + */ + void parseParameters() { + + if (parsedParams) { + return; + } + + synchronized (parameters) { + parameters = copyMap(getRequest().getParameterMap()); + mergeParameters(); + parsedParams = true; + } + } + + // ------------------------------------------------------ Protected Methods @@ -619,4 +602,44 @@ } + // ------------------------------------------------------ Private Methods + + + /** + * Merge the parameters from the saved query parameter string (if any), and + * the parameters already present on this request (if any), such that the + * parameter values from the query string show up first if there are + * duplicate parameter names. + */ + private void mergeParameters() { + + if ((queryString == null) || (queryString.length() < 1)) + return; + + HashMap queryParameters = new HashMap(); + String encoding = getCharacterEncoding(); + if (encoding == null) + encoding = "ISO-8859-1"; + try { + RequestUtil.parseParameters + (queryParameters, queryString, encoding); + } catch (Exception e) { + ; + } + synchronized (parameters) { + Iterator keys = parameters.keySet().iterator(); + while (keys.hasNext()) { + String key = (String) keys.next(); + Object value = queryParameters.get(key); + if (value == null) { + queryParameters.put(key, parameters.get(key)); + continue; + } + queryParameters.put + (key, mergeValues(value, parameters.get(key))); + } + parameters = queryParameters; + } + + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]