ServletException: Cannot create iterator for this collection
hi,
i am using struts action class with struts tags to display
data in jsp page.
in struts class i am return arraylist ,
same list i am displaing in jsp.
if Arraylist have data ,i am not getting error.
but if arraylist empty ,i am getting ServletException: Cannot create iterator for this collection
<logic:iterate id="result" name="fileList" >
<td><bean:write name="result" property="fileName"/></td>
</logic:iterate
can any one help how to avoid this exception?
thanks
siav>
[586 byte] By [
sivasaia] at [2007-10-3 1:47:28]

You could use <bean:size> to get the size of the list and conditionally execute the logic:iterate, something like this :
<bean:size id="id" name="collection" />
<logic:lessEqual value="0" name="id">
The length is zero
</logic:lessEqual>
<logic:greaterThan value="0" name="id">
//your logic:iterate here...
</logic:greaterThan>
> You could use <bean:size> to get the size of the list
> and conditionally execute the logic:iterate,
> something like this :
>
That will work, but not necessary. If the collection is empty, the iterate tag just skips - it doesnt throw an exception (tested)
The problem I guess is that the bean with the specified name is not a Collection. It may be a property of the bean that is a collection in which case the tag should have a property attribute.
ram.
I got the error Pl help
javax.servlet.jsp.JspException: ServletException in '/home.jsp': Cannot create iterator for this collection
this is the code
<logic:iterate name="result" property="numtrue" id="true" ></logic:iterate>
<logic:iterate name="result" property="nlphavalue" id="alpha" >
<bean:write name="result" property="numvalue" scope="request" />
</logic:iterate>
Pl help me
Bhagya
I got the error Pl help
javax.servlet.jsp.JspException: ServletException in '/home.jsp': Cannot create iterator for this collection
this is the code
<logic:iterate name="result" property="numtrue" id="true" ></logic:iterate>
<logic:iterate name="result" property="nlphavalue" id="alpha" >
<bean:write name="result" property="numvalue" scope="request" />
</logic:iterate>
Pl help me
Bhagya