Process flow ============ Index.jsp is supposed to execute the getCustomer() method in customerAction class. The customerAction is supposed to put a customers ArrayList object in the request scope. the customer.jsp screen is supposed to iterate through the customer ArrayList object that was placed in the request scope and display the data in their respective fields.
My objective is to display the data brought back from the database.
When I debugged CustomerAction class with these lines of code:
, I got the following out from the Arraylist object that is placed the the request scope:
((CustomerBean)i.next()).getFirstName(): OLA ((CustomerBean)i.next()).getFirstName(): OLATEST ((CustomerBean)i.next()).getFirstName(): SAUD
Please tell me the cause of the error and how to work round it. In any case, is there a more efficient way of achieving my objective?
Ola Oke Error ===== When I execute/run index.jsp screen I get the error below:
org.apache.jasper.JasperException: Cannot create iterator for this collection at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455) ...
index.jsp (This is the JSP the processing that leads to the error): =================================================================== <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <jsp:forward page="/customer.do?methodToExecute=getCustomer"/>
In your Form Bean Definitions, you only defined username and password.
But in the JSP, you use customerNo and firstName: <logic:iterate id="customer" name="customers"> <tr align="left"> <td><bean:write name="customer" property="customerNo"/>:</td> <td><bean:write name="customer" property="firstName"/>:</td> </tr> </logic:iterate>
Make them consistance to each other and try if it can slove your problem.
Joined: Sep 09, 2003
The formbean that I believe you are referring to is just an example embeded inside a comment. I have edited and reposted.