I am writing web application in struts 1.3. I want to pass ArrayList of Employees to JSP page.
I see following two approches :
1. Put List of Employee as a field into ActionForm.
List<Employee> employees;
Action class setting this field:
empForm.setEmployees(employeeList);
And JSP using this data as :
${empForm.employees}
2. Put the list of Employees directly into request.
Action class setting employeeList into request.
request.setAttribute("employees", employeeList);
And in JSP:
${employees}
Please suggest what approach should I go with. Which one is considered to be a good practice in Struts 1.3.
Both are correct. If the page required form you can put the list in the ActionForm. Personally I prefer setting inside ActionForm since it is more organized.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With