title: Retrieve file and parameters in jsp from POST request
body: <p>I have the following form inside a modal:</p>
  
  <pre><code>    &lt;div id="sazModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="sazModalLabel" aria-hidden="true"&gt;
        &lt;div class="modal-header"&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
          &lt;h3 id="sazModalLabel"&gt;Upload a Test&lt;/h3&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
         &lt;form method=POST id='sazForm' class="form-horizontal" action="upload.jsp" enctype='multipart/form-data'&gt;
            &lt;div class="control-group"&gt;
              &lt;label class="control-label" for="inputEmail"&gt;Email&lt;/label&gt;
              &lt;div class="controls"&gt;
                &lt;input name="email" type="text" id="inputEmail" placeholder="Email"&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class='control-group'&gt;
              &lt;label class='control-label' for='inputHost'&gt;Test Server&lt;/label&gt;
              &lt;div class='controls'&gt;
                  &lt;input name="hstnme" type='text' id='inputHost' placeholder='Hostname'&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class='control-group'&gt;
              &lt;label class='control-label' for='inputPort'&gt;Port Number&lt;/label&gt;
              &lt;div class='controls'&gt;
                  &lt;input name="port" type='text' id='inputPort' placeholder='Port'&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="control-group"&gt;
              &lt;label class="control-label" for="fileUploadButton"&gt;Saz File&lt;/label&gt;
              &lt;div class="controls"&gt;
                &lt;input name="saz" type="file" id="fileUploadButton" placeholder="Saz File"/&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;div id='modalfooter'&gt;
              &lt;input class="btn btn-success" type='submit' id='goButton' value="Go!"/&gt;
              &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>And I would like to have it send to the following jsp (upload.jsp):</p>
  
  <pre><code>&lt;%@ page import="java.io.*,java.util.*, javax.servlet.*"%&gt;
  &lt;%@ page import="javax.servlet.http.*"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.*"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.disk.*"%&gt;
  &lt;%@ page import="org.apache.commons.fileupload.servlet.*"%&gt;
  &lt;%@ page import="org.apache.commons.io.output.*"%&gt;
  
  &lt;%
     System.out.println(request.getParameter("hstnme"));
  
     Enumeration&lt;String&gt; paramNames = request.getParameterNames();
  
     while(paramNames.hasMoreElements()) {
        String paramName = (String)paramNames.nextElement();
        System.out.print(paramName + " : ");
        String paramValue = request.getHeader(paramName);
        System.out.println(paramValue);
     }
  %&gt;
  </code></pre>
  
  <p>I'm running into the problem that the parameters are not coming over properly. My System.out says:</p>
  
  <pre><code>null
  </code></pre>
  
  <p>and that's it. It's clearly not getting the other inputs (email, hstnme, and port). The null comes from the first .getParameter("hstnme")</p>
  
  <p>I thought that hostname might be protected in some way, so I changed it to hstnme, with no luck. I also notice that when I use the commons.fileupload, all four parameters are made into FileItems, but their values are not sent along. </p>
  
  <p>How do I pass the parameters in my form to the jsp and retrieve them correctly?</p>