JSTL: for Each loop to iterate over collection

13,405

It looks like the object called "location" does not have an fEvents property. Is it actually called ftpEvents? Do you need to just change the variable name?

Even with that, though, you'll probably want to do something more like this:

 <c:forEach items="${location.ftpEvents}" var="item">
    <tr><td><form:input path="item.hostName" size="30" maxlength="200"/></td>
    <td><form:input path="item.directory" size="30" maxlength="200"/></td>
    <td><form:input path="item.userName" size="20" maxlength="20"/></td>
    <td><form:input path="item.password" size="20" maxlength="20"/></td>
    </tr>
 </c:forEach>

...you don't need to even use the loop.index at all, if I'm interpreting your code correctly.

Share:
13,405
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    following is my snippet, which was working good untill I migrated from spring 2 to spring 3 and Jstl 1.1 to jstl 1.2. Now, its not working and keep on giving the error fEvents cannot found on object location

     <c:forEach items="${location.fEvents}" var="item" varStatus="loop">
        <tr><td><form:input path="fEvents[${loop.index}].hostName" size="30" maxlength="200"/></td>
        <td><form:input path="fEvents[${loop.index}].directory" size="30" maxlength="200"/></td>
        <td><form:input path="fEvents[${loop.index}].userName" size="20" maxlength="20"/></td>
        <td><form:input path="fEvents[${loop.index}].password" size="20" maxlength="20"/></td>
        </tr>
     </c:forEach>
    

    need to iterate the ftpEvents and show them on jsp Any suggestion is appreciated!!!

  • ach
    ach about 11 years
    I'm a bit confused, you say that the problem is still there but you accepted the answer? Is it still a problem, or not?
  • Admin
    Admin about 11 years
    its not..resolved...it was an issue with property name..was using correctly in all the places except in the hibernate config file..had two fields of same name one for boolean and one for collection..need to change one of the property name!