title: Jquery and HTML forms behaving differently
body: <p>The following page has two forms, one is a simple upload form with no decoration and other one is a decorated form using the library of jquery-ui. When I click on submit button of the regular form the data perfectly gets submitted, I mean the uploaded file goes to the desired folder perfectly, but when I use trigger the submit function of other form using a click of a button then the servlet gets called but the same parameters dont get passed to the servlet. I mean there is nothing getting posted to the servlet when I submit using the decorated form.</p>
  
  <p>HTML Code:  </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="./jquery.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" href="jquery-ui.css" /&gt;
  &lt;script type="text/javascript" src="jquery-ui.js"&gt;&lt;/script&gt;
  
  &lt;title&gt;&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="open-form"&gt;Upload your file&lt;/div&gt;
      &lt;div id="dialog-form" title="Select your file"&gt;
          &lt;form id="uploadForm" action="./uploadFile "
              enctype="multipart/form-data" method="POST"&gt;
              &lt;fieldset&gt;
                  &lt;label for="name"&gt;&lt;b&gt;Filepath&lt;/b&gt;&lt;/label&gt; &lt;input type="file"
                      class="text ui-widget-content ui-corner-all" id="name" /&gt;
              &lt;/fieldset&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  
      &lt;form action="./uploadFile" enctype=" multipart/form-data" method="POST"&gt;
          &lt;div class="box2"&gt;
                  Select your File&lt;/br&gt; 
                  &lt;input type="file" name="Uploaded file"&gt; 
                  &lt;input type="submit" class="button" value="Upload"&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  
      &lt;script type="text/javascript"&gt;
          $(function() {
  
              var name = $("#name"), allFields = $([]).add(name);
              $("#dialog-form").dialog({
                  autoOpen : false,
                  height : 300,
                  width : 460,
                  modal : true,
                  buttons : {
                      "Upload" : function() {
                          document.forms["uploadForm"].submit();
                      },
                      Cancel : function() {
                          $(this).dialog("close");
                      }
                  },
                  close : function() {
                      allFields.val("").removeClass("ui-state-error");
                  }
              });
              $("#open-form").click(function() {
  
                  $("#dialog-form").dialog("open");
  
              });
  
          });
      &lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>adding javascript in the tags just to be sure.
  this is the servlet code:</p>
  
  <pre><code>public void doPost(HttpServletRequest req, HttpServletResponse res) {
          try {           
              int formDataLength = req.getContentLength();
              byte dataBytes[] = new byte[formDataLength];
              DiskFileItemFactory factory = new DiskFileItemFactory();
              factory.setSizeThreshold(4096);
              factory.setRepository(new File("/location/y-folder"));
              ServletFileUpload upload = new ServletFileUpload(factory);
              upload.setSizeMax(10000000);
              List fileItems = upload.parseRequest(req);           
              Iterator i = fileItems.iterator();
              FileItem fi = ((FileItem) i.next());
              InputStream inputStream = fi.getInputStream();
              String path = fi.getName();
              long h = fi.getSize();
              File f = new File("/location/x-folder"+path);
              OutputStream out = new FileOutputStream(f);
              int len;
              while ((len = inputStream.read(dataBytes)) &gt; 0) {
                  out.write(dataBytes, 0, len);
              }
              out.close();
              inputStream.close();
  
              System.out.println("Fi:-" + fi.toString());
  }catch(Exception e){
  system.out.println(e);
  }
  </code></pre>