title: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
body: <p>I have a Bean that holds  the results. I need to use JSTL to iterate over it and present the results. Here is the bean:</p>
  
  <pre><code>public class DetResults
  {
      private List&lt;String&gt; headings;
      private List&lt;Class&lt;?&gt;&gt; types;
      private List&lt;Object[]&gt; data;
  
      public DetResults() {}
  
      public List&lt;String&gt; getHeadings() { return this.headings; }
      public String getHeading(int which) { return this.headings.get(which); }
  
      public List&lt;Class&lt;?&gt;&gt; getTypes() { return this.types; }
      public Class&lt;?&gt; getType(int which) { return this.types.get(which); }
  
      public List&lt;Object[]&gt; getData( ) { return this.data; }
      public Object[] getDataAtRow( int row ) { return this.data.get(row); }
  
  
      public void setHeadings( List&lt;String&gt; val ) { this.headings = val; }
      public void setHeadings( String[] val ) { this.headings = Arrays.asList(val); }
      public void addHeading( String val ) 
      { 
          if( this.headings == null ) this.headings = new ArrayList&lt;String&gt;();
          this.headings.add(val); 
      }
  
      public void setTypes( List&lt;Class&lt;?&gt;&gt; val ) { this.types = val; }
      public void setTypes( Class&lt;?&gt; val[] ) { this.types = Arrays.asList(val); }
      public void addType( Class&lt;?&gt; val ) 
      {
          if( this.types == null ) this.types = new ArrayList&lt;Class&lt;?&gt;&gt;();
          this.types.add(val); 
      }
  
  
      public void setData( List&lt;Object[]&gt; val ) { this.data = val; }
  
      // allow NPE to get thrown
      public void setDataAtRow( Object[] val, int row ) { this.data.set(row, val); }
  
      public void appendDataRow( Object[] val ) 
      {
          if( data == null ) data = new ArrayList&lt;Object[]&gt;(); 
          this.data.add(val); 
      }
  
      public int getColumnCount() { return this.headings!=null?this.headings.size():0; }
  
  }
  </code></pre>
  
  <p>Here is the handler that will set the bean to the JSP:</p>
  
  <pre><code>DetResults results = detDAO.fetchDetResults(paramBean);
  request.setAttribute("results", results);
  action.setJspURI(".../.jsp");
  </code></pre>
  
  <p>I tried to display it as follows:</p>
  
  <pre><code>&lt;c:forEach var="results" items="${results}"&gt;
      ${results.heading}
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>But it threw the following exception:</p>
  
  <blockquote>
    <p>Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don&#039;t know how to iterate over supplied &quot;items&quot; in &lt;forEach&gt;</p>
  </blockquote>
  
  <p>If I log the results on my handler page like this:</p>
  
  <pre><code>System.out.println( "\n\nthere are " + results.getColumnCount() + " columns in the result set" );
  for( int i=0; i&lt;results.getColumnCount(); i++ )
  {
      System.out.println( results.getHeading(i) + " --&gt; " + results.getType(i) );
  }
  </code></pre>
  
  <p>The logging seems to show fine on the server.</p>