title: jstl - forEach, bean having a list of beans as property
body: <p>I have a bean called Experiment which has a property that is a arraylist of beans of a type called Assay.</p>
  
  <p>In a jsp I want to iterate over the list of assays stored in an Experiment bean, which I try to do by doing this:</p>
  
  <pre><code>                &lt;c:forEach items="${exp.assays}" var="ay"&gt;
                      &lt;tr&gt;&lt;td&gt;${ay.decision}&lt;/td&gt;&lt;td&gt;${ay.comment}&lt;/td&gt;&lt;/tr&gt;
                  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>'descision' and 'comment' are properties of the Assay bean. </p>
  
  <p>But this doesn't work. I get the error: </p>
  
  <pre><code>SEVERE: javax.el.PropertyNotFoundException: The class 'beans.Experiment' does not have the property 'decision'.
  </code></pre>
  
  <p>as if the items in the 'exp.assays' list where of bean type Experiment and not of Assay as I would expect.</p>
  
  <p>So I tried accessing Experiment property (eid, which I know I can access by directly writing ${exp.eid}) in the forEach-loop instead, like this:</p>
  
  <pre><code>                &lt;c:forEach items="${exp.assays}" var="ay"&gt;
                      &lt;tr&gt;&lt;td&gt;${ay.eid}&lt;/td&gt;&lt;/tr&gt;
                  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>but then I got the error message:</p>
  
  <pre><code>SEVERE: javax.el.PropertyNotFoundException: The class 'beans.Assay' does not have the property 'eid'. 
  </code></pre>
  
  <p>Anyone who knows what is going on or how I could fix it?</p>
  
  <p>The full bean code is pretty long but here are the parts that I think are relevant here</p>
  
  <p>Experiment:</p>
  
  <pre><code>public class Experiment extends dataItem implements Serializable {
  
      private String eid;
      private List&lt;Assay&gt; assays = new ArrayList();
  
      public String getEid() {
          return eid;
      }
  
      public void setEid(String id) {
          eid = id;
      }  
  
      public List&lt;Assay&gt; getAssays() {
          return assays;
      }
  
      public void setAssays(List&lt;Assay&gt; assays) {
          this.assays = assays;
      }
  
  }
  </code></pre>
  
  <p>And Assay:</p>
  
  <pre><code>public class Assay extends dataItem implements Serializable {
  
      private Integer id;
      private stock antigen;
      private String decision;
      private String comment;
      private String freeAb;    
      private List&lt;AssayData&gt; data;
      private List&lt;conjugate&gt; conjugates = new ArrayList();
  
      public List&lt;conjugate&gt; getConjugates() {
          return conjugates;
      }
  
      public void setConjugates(List&lt;conjugate&gt; conjugates) {
          this.conjugates = conjugates;
      }   
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public stock getAntigen() {
          return antigen;
      }
  
      public void setAntigen(String id) {
          stock s = new stock();
          s.setSID(id);
  
          this.antigen = s;
      }
  
      public String getDecision() {
          return decision;
      }
  
      public void setDecision(String decision) {
          this.decision = decision;
      }
  
      public String getComment() {
          return comment;
      }
  
      public void setComment(String comment) {
          this.comment = comment;
      }
  
      public String getFreeAb() {
          return freeAb;
      }
  
      public void setFreeAb(String freeAb) {
         this.freeAb = freeAb;
      }
  
      public List&lt;AssayData&gt; getData() {
         return data;
      }
  
      public void setData(List&lt;AssayData&gt; data) {
         this.data = data;
      }   
  }
  </code></pre>