title: How to send hidden input parameters in Multipart form to the server
body: <p>I have below HTML form. Please notice below hidden input fields have the <strong>same name</strong> (ie. "<em>days_of_the_week</em>"). </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;form enctype="multipart/form-data" name="myForm" method="post"&gt;
  
          &lt;input type="file" name="myfile"&gt;
  
          &lt;input type="hidden" name="days_of_the_week" id="day1" value="Sunday" /&gt;
          &lt;input type="hidden" name="days_of_the_week" id="day2" value="Monday"  /&gt;
          &lt;input type="hidden" name="days_of_the_week" id="day3" value="Tuesday"  /&gt;
          &lt;input type="hidden" name="days_of_the_week" id="day4" value="Wednesday"  /&gt;
          &lt;input type="hidden" name="days_of_the_week" id="day5" value="Thursday"  /&gt;
          &lt;input type="hidden" name="days_of_the_week" id="day6" value="Friday"  /&gt;
          &lt;input type="hidden" name="days_of_the_week" id="day7" value="Saturday"  /&gt;
  
          &lt;input type="submit" value="Submit"&gt;    
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Also assume that there can be any number of hidden fields in the HTML form with the same name or with different names. 
  Ex:</p>
  
  <pre><code>&lt;input type="hidden" name="abc" id="abc1"  /&gt;
  &lt;input type="hidden" name="abc" id="abc2"  /&gt;
  
  &lt;input type="hidden" name="pqr" id="pqr1" /&gt;
  
  &lt;input type="hidden" name="xyz" id="xyz1" /&gt;
  &lt;input type="hidden" name="xyz" id="xyz2" /&gt;
  </code></pre>
  
  <p>Earlier above HTML form was not a multipart form. Therefore I could retrieve hidden input values on server side as an array using below code line.</p>
  
  <pre><code>// here request is the usual HttpServletRequest object. 
  String[] parameterArray = request.getParameterValues("days_of_the_week"); 
  // Thus parameterArray = {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}
  </code></pre>
  
  <p>But after adding <code>multipart/form-data</code> attribute, now above code line returns <code>null</code> and Therefore <code>parameterArray  = null</code>. So as per my understanding, hidden values are not sent to the server as usual when we add <code>multipart/form-data</code> attribute.</p>
  
  <p>So my questions are,</p>
  
  <p>Is there a way to force hidden values to be sent to the server so that we can read them from <code>request.getParameterValues("days_of_the_week");</code> as usual?</p>
  
  <p>If not, what is the best way to achieve above requirement? I can create a List on server side and fill it as below. But when there are any number of such hidden fields in the HTML form as described above, I may have to repeat <code>if(item.getFieldName().equals("hidden_field_name"))</code> condition check for each and every distinct hidden field name which is not so smart for me.   </p>
  
  <pre><code>DiskFileItemFactory factory = new DiskFileItemFactory();
  ServletFileUpload upload = new ServletFileUpload(factory);
  
  List&lt;String&gt; daysOfWeek = new ArrayList();
  
  List requestList = upload.parseRequest(request);
  for (Iterator iterator = requestList.iterator(); iterator.hasNext();) {
      FileItem item =  (FileItem) iterator.next();
      if(item.isFormField()){
          if(item.getFieldName().equals("days_of_the_week")){
              daysOfWeek.add(item.getString());
          }  
      }
  }
  </code></pre>
  
  <p>I really appreciate any suggestions or solutions for the above question.</p>