Search code examples
javajspjstljavabeans

JSTL cannot find bean that is a forEach iteration


I have a collection of these objects:

public class Selection
{
    private List<Option> options = new ArrayList<Option>();

    ... getter /setter ...
}

In my JSP I do this:

<c:forEach var="selection" items="${selections}">

    ... numerous uses of selection that work fine ...

    <html:select name="selection" property="option" 
        indexed="true" styleId="option_${selection.option.id}"
        title="Option" styleClass="reasonsel" 
        disabled="false" >
        <html:options collection="selection.options" property="id" labelProperty="description"/>
    </html:select>
</c:forEach>

And I'm getting:

javax.servlet.jsp.JspException: Cannot find bean: "selection.options" in any scope

I have confirmed in the debugger that the selection object exists and has options.


Solution

  • <html:options collection="${selection.options}" property="id" labelProperty="description"/>
    

    you should use el tag to retrieve value for that.