title: How to retrieve uploaded file using ajax on java server side?
body: <p>I am using struts2 framework on server side. I am uploading a file using </p>
  
  <p>server side :</p>
  
  <pre><code>&lt;s:file name="fTU" id="fTU"/&gt;
  
  &lt;input type="submit" value ="ok" onclick="upload()"&gt;
  </code></pre>
  
  <p>client side :</p>
  
  <pre><code>function upload(){
  
  var file = document.getElementById("fTU");
  
  try {
      this.xml = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
      try {
          this.xml = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (err) {
          this.xml = null;
      }
  }
  if(!this.xml &amp;&amp; typeof XMLHttpRequest != "undefined")
      this.xml = new XMLHttpRequest();
  if (!this.xml){
      this.failed = true; 
  }
  
  var formData = new FormData();
  /* Add the file */ 
  formData.append("upload", file.files[0]);
  </code></pre>
  
  <p>xml.open("POST", "", true);
      xml.setRequestHeader("Content-Type", "false");</p>
  
  <pre><code>xml.send(formData);  /* Send to server */
  
  xml.onreadystatechange = function () {
      if (xml.readyState == 4 &amp;&amp; xml.status == 200) {
          alert(xml.statusText);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>How to fetch the uploaded file object on struts2 server side?</p>
  
  <p>It is going in server side class and I am trying to retrieve file by using request.getParameter(upload) but it is giving null.</p>