[opencms-dev] Possible bug using I_CmsRequest getParameterValues() with multipart/form-data form and multi valued checkbox

J-Guillaume Battaglia djidje78 at yahoo.fr
Fri Mar 26 18:29:01 CET 2004


Hi everybody.

It's the fourth time I try to send this message (I tried three times with a different mail adress
but it never arrived so I subscribed with my personal e-mail).
Hope you won't receive it four time.

With the following form in a JSP :
<form name="rechercheProcedure"
      method="post"
      action="creationModificationDocument.jsp"
      enctype="multipart/form-data">
  <input type="checkbox" name="channelIds" id="checkboxChannel1" value="1"/>
  <input type="checkbox" name="channelIds" id="checkboxChannel2" value="2"/>
  <input type="checkbox" name="channelIds" id="checkboxChannel3" value="3"/>
  <input type="checkbox" name="channelIds" id="checkboxChannel4" value="4"/>
  <input type="file" name="fileToUpload" >
</form>


I use the following code to log the cmsRequest :
public static Logger logger = Logger.getLogger(MyClass.class);

public void logCmsHttpRequestParameters(CmsObject cmsObject) {
  StringBuffer cmsHttpRequestParameters = new StringBuffer();
  // [..] Different test to avoid NullPointerException
  cmsHttpRequestParameters.append("\r\n Paramètres de la requête HTTP d'OpenCMS :");
  Enumeration params = cmsRequest.getParameterNames();
  if (params == null) {
    cmsHttpRequestParameters.append("\r\n cmsRequest.getParameterNames() :" + params);
  } else {
    while(params.hasMoreElements()) {
      String paramName = (String)params.nextElement();
      if (paramName == null) {
        cmsHttpRequestParameters.append("\r\nparamName = " + paramName);
      } else {
        String parameterValues[] = cmsRequest.getParameterValues(paramName);
        if (parameterValues == null || parameterValues.length == 0) {
          String parameterValue = cmsRequest.getParameter(paramName);
          cmsHttpRequestParameters.append("\r\n(" + paramName + ", only one value : " +
parameterValue + ")");
        } else {
          cmsHttpRequestParameters.append("\r\n(" + paramName + ", " + parameterValues.length + "
value(s) : ");
          for (int i = 0; i < parameterValues.length; i++) {
            cmsHttpRequestParameters.append(parameterValues[i]);
            if (i == parameterValues.length - 1) {
              cmsHttpRequestParameters.append(")");
            } else {
              cmsHttpRequestParameters.append(", ");
            }
          }
        }
        cmsHttpR equestParameters.append("\r\n");
        logger.debug(cmsHttpRequestParameters.toString());
      }
    }
  }
}

For the parameter channelIds, even when I check several values, I only get one in my log message,
for example :
(channelIds, only one value : 2)

I checked in the class CmsRequestHttpServlet and I found the following code :
public String[] getParameterValues(String key) {
    return m_req.getParameterValues(key);
}

It means that for single valued parameters, this class reads the ServletInputStream to
"regenerate" parameters but for multi valued parameters, it only returns the parameters in the
HttpServletRequest, which are null because with a multipart/form-data form they are not sent.

I didn't find anything in bugzilla.

So what can I do ?

TIA for any help.


                          Jean-Guillaume.


	

	
		
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com



More information about the opencms-dev mailing list