How to Upload Multiple Files Using Struts

Written by joshua laud
  • Share
  • Tweet
  • Share
  • Email

If you use the Apache Struts Java framework along with your Apache web server, you can use it to upload files without the need for further scripting. Struts features a built-in file uploader that can be called on using very basic HTML forms. This is the simplest way to upload a file using Struts as it allows you to use any HTML customisation for the design and development that you want. Once set up, you can use this form as many times as you wish. This form will allow you to highlight multiple files for upload.

Skill level:


  1. 1

    Click "Start," type "notepad" and press "Enter." In this example you can use Notepad to edit your HTML document, but if you prefer to use a more advanced editor you can. Make sure you switch to the "HTML" mode within the program.

  2. 2

    Type the following code:

    import org.apache.struts.upload.FormFile;

    public class MyActionForm extends ActionForm {
       private FormFile my File;
       public void setMyFile(FormFile my File) {
           this.myFile = my File;
       public FormFile getMyFile() {
           return my File;
  3. 3

    Click "File > Save As." Click the file type drop-down and select "All Files." Title this document "" and save it to the main web server folder.

  4. 4

    Press "Ctrl + O." Locate and open the web page to which you wish to add the upload form.

  5. 5

    Type the following code where you want the form to go:

    <form name="Form" method="post" action="/path/to/" enctype="multipart/form-data">

         Select File: &lt;input type="file" name="myFile"&gt; &lt;/br&gt;
         &lt;input type="submit" value="Upload File"&gt;


    Change the "path/to" to direct to the "" in relation to the existing web page. Save the page and the form is in place.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.