title: Upload multiple files at once to a Struts2 @Action
body: <p>I need to upload "1000 files" or "a zip file including all the files" at once using Struts2. (By 1000 Files or a zip file, I mean I need all the files to be uploaded on the system it does not matter if user choose all the 1000 files at once or zip them and upload as a single file, so I am looking for the one which is easier to implement and more efficient)</p>
  
  <p>I have read the following answers but none of them suits the purpose.</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/8322499/struts2-file-upload/">Struts2 File Upload</a></li>
  <li><a href="https://stackoverflow.com/questions/1175347/how-can-i-select-and-upload-multiple-files-with-html-and-php-using-http-post">How can I select and upload multiple files with HTML and PHP, using HTTP POST?</a></li>
  </ul>
  
  <p>Using the following code, when I use a simple List files; it shows name of lists, but when I use List  files it does not show any thing and I can not upload the files.</p>
  
  <p><strong>upload.jsp</strong></p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;JSP Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="upload" enctype="multipart/form-data" method="post"&gt;
              &lt;input name="files" type="file" multiple/&gt;
              &lt;button type="submit"/&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>upload.java</strong></p>
  
  <pre><code>@Action
  public class upload implements Addresses {
  
      private List &lt;File&gt; files = new ArrayList &lt;File&gt; ();
  
      public String execute(){
  
          return "success";
      }
      public upload() {
          System.out.println("in upload 1");
  
           for(int i=0;i&lt;files.size();i++)
              System.out.println(i + ")" + files.get(i));
  
          System.out.println("in upload 2");
      }
  
      public List &lt;File&gt; getFiles() {
          return files;
      }
  
      public void setFiles(List &lt;File&gt; files) {
          this.files = files;
          for(int i=0;i&lt;files.size();i++)
              System.out.println(i + ")" + files.get(i));
  //            File fileToCreate = new File("c:\image", files.get(i).toString());
  //            FileUtils.copyFile(files.get(i), fileToCreate);
      }
  }
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>in upload 1
  in upload 2
  </code></pre>