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 6808819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:00:09+00:00 2026-05-26T20:00:09+00:00

Using Struts 1.3. Submitting forms as a collection using the <logic:iterate> tag I’d like

  • 0

Using Struts 1.3.

Submitting forms as a collection using the <logic:iterate> tag I’d like to format multiple records of user to edit values.

When the data is submitted back to the Action how can it handle a list of form in an Action form? Is there a way to submit the results as a collection of forms?

For example, I have List<EmployeeForm> and I am iterating these records on my jsp page and it’s working fine. But the records are editable on the JSP page, so after modifying the records and pressing the submit button I need the List<EmployeeForm> with updated records inside my action class to update the records inside the DB.

update, my jsp page is below given:

<html:form action="modify.do" styleId="LogicIterateForm" method="post">
            <table style="font-weight:bold">
            <tr><td>Employee ID</td><td>Employee Name</td></tr>
            <logic:iterate id="employee" name="LogicIterateForm" property="emp" indexId="i">

           <tr>

enter code here

           </tr>
        </logic:iterate>
<tr>
    <html:submit onclick="submitForm()">Modify</html:submit>
</tr>
    </table>
        </html:form>

action: to perform on clicking of Modify button

LogicIterateForm logicIterateForm=(LogicIterateForm)form;
        List<Employee> empList=logicIterateForm.getEmp();
        System.out.println("Size of emp:::::"+empList.size());
        if(empList!=null && empList.size()>0)
        {
            for(Employee emp:empList)
            {
                if(emp!=null)
                {
                    System.out.println("EmployeeID:::::::::::"+emp.getEmpId());
                    System.out.println("EmployeeName:::::::::::"+emp.getEmpName());
                }
            }
        }

and it is working fine to send the list of employees inside the action but unfortunately i am unable to get the updated form fields value inside my action. please help me where i am doing mistake.

and below is my ActionForm

public class LogicIterateForm extends org.apache.struts.action.ActionForm {


    private List<Employee> emp=new ArrayList<Employee>();


    public List<Employee> getEmp() {
        return emp;
    }

    public void setEmp(List<Employee> emp) {
        this.emp = emp;
    }

and Employee class is a plan java class with setter and getter of empId and empName

  • 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-05-26T20:00:10+00:00Added an answer on May 26, 2026 at 8:00 pm

    The nutshell version is that the generated HTML will have an incorrect name attribute. The ActionForm list property is named emp but you’re calling it employee.

    The longer version includes some other miscellaneous stuff that should make things a little easier for you in the long run.

    First, here’s the Action I used to display the form. Note that I am not putting anything into scope explicitly–the framework does this for us. It appears as though you’re explicitly setting a form into scope for use by <logic:iterator>, but that’s redundant.

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        Employee emp1 = new Employee("1", "Dave");
        Employee emp2 = new Employee("2", "Subodh");
        ((LogicIterateForm) form).setEmp(Arrays.asList(emp1, emp2));
        return mapping.findForward("success");
    }
    

    Second, the JSP page can be made simpler because of the above. Note that the name of the input element must match the name in the form, emp, otherwise Struts won’t know what to do with the input value, and it will be ignored.

    <logic:iterate name="empForm" property="emp" id="emp">
      <tr>
        <td><html:text name="emp" value="${emp.empId}" property="empId" indexed="true"/></td>
        <td><html:text name="emp" value="${emp.empName}" property="empName" indexed="true"/></td>
      </tr>
    </logic:iterate>
    

    Then inside the action that’s being submitted to all the data will be in the form as expected.

    List<Employee> emps = ((LogicIterateForm) form).getEmp();
    for (Employee emp : emps) {
        System.out.printf("%s: %s%n", emp.getEmpId(), emp.getEmpName());
    }
    

    That should do it.

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

Sidebar

Related Questions

I am using Struts 1 framework and i have a query regarding the logic:iterate
I'm using struts select tag in my forms.I use a Hash map to populate
I have Map type. I want to iterate over it using struts tag library.
I'm using Struts 2 . I'd like to return from an Action to the
I'm using Struts 2 and I'd like to determine the page generation time without
I'm writing a Java application using Struts 2, but now I'd like to make
I iterate a list using Struts 2 tags. <s:iterator value=popUpScreenDetailsList status =rowCounter> //do something
How assign the hidden value using Struts tag inside of iteration. My JSP code
I am using struts 1.1 with tiles. I have tiles with definitions like <definition
I'm using struts 2 <s:form> tag. Now I want use design prepared by our

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.