tags:

views:

76

answers:

2

Hello, in my jsp i do this

<table>
 <tr>
  <th>TITLLE</th>
 </tr>  
 <tr class="row0"> 
  <logic:iterate id="listClient"      name="Client">       
   <td>
    [...]
   </td>
  </logic:iterate>
 </tr>
</table>

<logic:iterate id="listClient" name="Client">
 <table>
  <tr>
   <td>
    [...]
   </td>
  </tr>
 </table>
</logic:iterate>

But i have this error for my second iterate

javax.servlet.jsp.JspException: Cannot create iterator for this collection

A: 

You are using the same id, change the id of the second one

medopal
when i change the id for the second iterator i have the same errorjavax.servlet.jsp.JspException: Cannot create iterator for this collection
Mercer
+1  A: 

The Cannot create iterator for this collection message is thrown by the iterate tag when it is not able to create an iterator for the collection you are passing to it.

The tag extracts an object from scope using the specified name, in this case Client and starts to check what type it is:

  • array of objects or primitives;
  • java.util.Collection;
  • java.util.Iterator;
  • java.util.Map;
  • java.util.Enumeration.

If it finds one of this object types it extracts the iterator in the appropriate way. If none of the above are a match you get javax.servlet.jsp.JspException: Cannot create iterator for this collection.

At this point I agree with Adeel Ansari's comment: "it doesn't make any sense to me when you are able to iterate once, but not again".

Are you doing something to the Client bean between the two iterator tags (i.e. is the presented code continuous in regards of the iterator tags)? Maybe you overwrite it with something that ain't a collection?

dpb