I use Struts V1.3 for a project. Here is my Action Class which I want to send an arrayList through request.settAttribute in execute function.
public class ProductAction extends Action { private List productList;
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Product product1 = new Product();
product1.setProductName("productName1");
product1.setProductCategory("productCategory1");
product1.setProductPrice(15.33);
product1.setProductDescription("productDescription1");
Product product2 = new Product();
product2.setProductName("productName2");
product2.setProductCategory("productCategory2");
product2.setProductPrice(15.454543);
product2.setProductDescription("productDescription2");
productList = new ArrayList<Product>();
productList.add(product1);
productList.add(product2);
request.setAttribute("products", productList);
return mapping.findForward("success");
}
As you see I want to send an ArrayList of Product where Product is a POJO.
Here is my JSP code which I expect to get "${products}" from the Action class.
<c:forEach items="${products}" var="product">
<tr>
<td>${product.productName}</td>
<td>${product.productCategory}</td>
<td>${product.productDescription}</td>
<td>${product.productPrice}</td>
</tr>
</c:forEach>
My problem is that in forEach I don't recieve anything(Even tr will not appear). How does I can assure that I get the ArrayList in action calss in JSP?
And here is my action-mapping
<action name="product" path="/product" type="view.ProductAction" scope="session">
<forward name="success" path="/productList.jsp" redirect="true"/>
<forward name="failure" path="/success.jsp" redirect="true"/>
</action>