tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Taylor <>
Subject Re: <c:forEach> problem
Date Tue, 29 Mar 2005 19:09:52 GMT
Hi Nitin,

Your problem is in your "items" attribute on the forEach tag. You are
passing it a string-- you need to pass it the actual object. Like this:

<c:forEach var="directory" items="${CONTEXT_STRUCTURE.directories}">

You were not giving it as an expression (ie. the ${ ... }), so c:forEach
was was interpreting it as a string and iterating over the tokens in the
string. Give it a try as an expression and it should fix your problem.

Hope this was able to help.


nitin dubey wrote:

>My JSP code looks like this..
><c:if test="${! empty CONTEXT_STRUCTURE.directories}">
><c:forEach var="directory"
>items="CONTEXT_STRUCTURE.directories" >
><td width="57%"><c:out value="${}"
><td width="22%">Template</td>
><td width="21%">&nbsp;</td>
>CONTEXT_STRUCTURE will return an Object of class
>ContextStructure from the session scope. The sole two
>members in ContextStructure class is ArrayList
>directories, Arraylist files with its setters and
>getters. This ArrayList further has ContextItem class
>instances that has properties like name and path with
>its setters and getters.
>I am getting an exception
>Unable to find a value for "name" in object of class
>"java.lang.String" using operator "."
>when I try to access the name property of the
>ContextItem object as in the JSP code.
>Could anyone tell me where I am getting wrong ?
>Nitin Dubey
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message