Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:53:26+00:00 2026-06-05T17:53:26+00:00

I have the following in my Struts ActionForm private List<FormFile> attachmentList = new ArrayList<FormFile>();

  • 0

I have the following in my Struts ActionForm

private List<FormFile> attachmentList = new ArrayList<FormFile>();

public MyForm() {
    for (int i = 0 ; i < 5 ; i++) {
        getAttachmentList().add(null);
    }
}

public List<FormFile> getAttachmentList() {
    return attachmentList;
}

public void setAttachmentList(List<FormFile> attachmentList) {
    this.attachmentList = attachmentList;
}

public FormFile getAttachmentList(int index) {
    return getAttachmentList().get(index);
}

public void setAttachmentList(int index, FormFile formFile) {
    getAttachmentList().set(index, formFile);
}

And in my JSP I have the following

<c:forEach var="counter" begin="0" end="4">
    <input type="file" name="attachmentList[${counter}]" size="50" />
</c:forEach>

Everything works fine, unless the validate method of the ActionForm finds errors (usually related to other fields on the form). When the form reloads, the file inputs are no longer populated. I added an assert right before the display Action returns the reloaded page, and the ActionForm has the right number of attachments (their file names are not blank etc).

Does anyone know how to make the files bind and stay?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:53:27+00:00Added an answer on June 5, 2026 at 5:53 pm

    File fields cannot be pre-filled; this is a well-known browser thing and has nothing to do with Struts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Action class have the following methods, 1.add 2.edit 3.loadEdit 4.remove 5.list 6.execute in
i have the following action class: package com.pendulum.web; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest;
I have the following code in a jsp page (Struts backed): <c:if test=${USERINFO.someproperty ==
I'm using Spring and struts and have the following entry in '/META-INF/context.xml' <Context cachingAllowed=false
I have the following action declared in my struts.xml: <action path=/updateAccountInfo type=org.myCompany.UpdateAccountAction name=myAccountForm scope=session
I am new to strut 2 though I have worked on struts 1.2.In one
my situation is the following: I have a project with JSP, Struts and a
I have a project with the following setup: Tomcat 6.x Struts 2.1.6 DisplayTag 1.2
I have the following problem in Struts 2. Let's assume i have a class
I'm using Spring and struts and have the following entry in 'C:/source/webapp/WebContent/META-INF/context.xml' with tokens

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.