title: How to fetch a column from a table(Persistence Database table) into a 'select' list of 'form' in a jsp page
body: <p>I want to fetch a column from a table(Persistence Database table) into a 'select' list of 'form' in a jsp page.
  I am using struts2 and hibernate.</p>
  
  <p>My column is 'name' and table is 'Category'
  I have made the mapping configuration and bean classes.</p>
  
  <p>code in a 'form' of a jsp page :</p>
  
  <pre><code>&lt;s:select label="Select Category :" name="cname" list="categoryList" /&gt;
  </code></pre>
  
  <p>My action class : </p>
  
  <pre><code>package com.rambo.action;
  
  import beans.Category;
  import com.opensymphony.xwork2.ActionSupport;
  import java.util.ArrayList;
  import java.util.List;
  import org.hibernate.Session;
  
  public class FindCategory extends ActionSupport {
  
      private List&lt;Category&gt; cl = new ArrayList&lt;Category&gt;();
      private List&lt;String&gt; categoryList = new ArrayList&lt;String&gt;();
  
      @Override
      public String execute() throws Exception {
          Session session = null;
          try {
              session = HibernateUtil.getSessionFactory().getCurrentSession();
              session.beginTransaction();
              this.cl = (List&lt;Category&gt;) session.createQuery("from Category").list();
              if (this.cl.isEmpty()) {
                  this.addActionError("Sorry.. No category Available. Try again Later.!");
                  return ERROR;
              }
              for (int i = cl.size()-1; i &gt;= 0; i--) {
                  categoryList.add(cl.get(i).getName());
              }
              session.getTransaction().commit();
          } catch (Exception e) {
              this.addActionError("Oops. An Error Encountered...!");
              return ERROR;
          }
          return SUCCESS;
      }
  }
  </code></pre>
  
  <p>Mapping in Category.hbm.xml :</p>
  
  <pre><code>&lt;property name="name" type="string"&gt;
              &lt;column name="NAME" length="20" not-null="true" /&gt;
          &lt;/property&gt;
  </code></pre>
  
  <p>Getter and setter of the bean "Category.java":</p>
  
  <pre><code>public String getName() {
          return this.name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  </code></pre>
  
  <p>My glassfish server shows error as :</p>
  
  <pre><code>org.apache.jasper.JasperException: tag 'select', field 'list', name 'cname': The requested list key 'categoryList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
  
  root cause tag 'select', field 'list', name 'cname': The requested list key 'categoryList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
  </code></pre>
  
  <p>Can some one please point out what may b the error..?
  thanks in advance.</p>