title: Getting error on selecting a value from a drop down select
body: <p>I want to fetch a selected value from a drop down 'select' list of 'form' in a jsp page into a variable defined in the action class of the form, where 'select' drop down list is itself fetched dynamically from a column 'name' of database table 'Category' with the list 'categoryList' which is defined in some another action class.</p>
  
  <p>After fetching the selected value (that is a name of Category) i want to fetch the primary key 'cid' of the table 'Category'. columns of Category are : id, name</p>
  
  <p>After Retrieving the 'cid' of the category i want to fill this cid in the column 'cid' of   another table 'Question'.</p>
  
  <p>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>My code of action class where the list is generated :</p>
  
  <pre><code>public class FindCategory extends ActionSupport {
  
      private List&lt;Category&gt; categoryList = new ArrayList&lt;Category&gt;();
  
      @Override
      public String execute() throws Exception {
          Session session = null;
          try {
              session = HibernateUtil.getSessionFactory().getCurrentSession();
              session.beginTransaction();
              this.categoryList = (List&lt;Category&gt;) session.createQuery("from Category").list();
              if (this.categoryList.isEmpty()) {
                  this.addActionError("Sorry.. No category Available. Try again Later.!");
                  return ERROR;
              }
              session.getTransaction().commit();
          } catch (Exception e) {
              this.addActionError("Oops. An Error Encountered...!");
              return ERROR;
          }
          return SUCCESS;
      }
  
      public List&lt;Category&gt; getCategoryList() {
          return categoryList;
      }
  
      public void setCategoryList(List&lt;Category&gt; categoryList) {
          this.categoryList = categoryList;
      }
  }
  </code></pre>
  
  <p>code in a 'form' of a jsp page :</p>
  
  <pre><code>&lt;s:form action="okadddqs" method="post" cssClass="text"&gt;
                                  &lt;input type="hidden" name="email" value="goods.ramesh@gmail.com"/&gt;
                                  &lt;s:select label="Select Category :" name="name" list="categoryList" listkey="name" listValue="name"/&gt; //Here the list is generated
                                  &lt;s:textarea label="Your Question " cols="40" rows="5" name="body"/&gt;
                                  &lt;s:textfield name="op1" label="Option 1 :"/&gt;
                                  &lt;s:textfield name="op2" label="Option 2 :"/&gt;
                                  &lt;s:textfield name="op3" label="Option 3 :"/&gt;
                                  &lt;s:textfield name="op4" label="Option 4 :"/&gt;
                                  &lt;s:textfield name="op5" label="Option 5 :"/&gt;
                                  &lt;s:select label="Correct Option :" 
                                           name="opc"       
                                           list="#@java.util.LinkedHashMap@{'1':'One',
                                           '2':'Two','3':'Three','4':'Four','5':'Five'}"/&gt;
                                  &lt;s:submit value="Update Daily Question"/&gt;
                              &lt;/s:form&gt;
  </code></pre>
  
  <p>My action to submit a new question class : </p>
  
  <pre><code>package com.rambo.action;
  
  import beans.Category;
  import beans.Question;
  import beans.Users;
  import com.opensymphony.xwork2.ActionSupport;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.StringTokenizer;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.SessionScoped;
  import org.hibernate.Session;
  
  /**
   *
   * @author ROMO
   */
  @ManagedBean
  @SessionScoped
  public class NewQuestion extends ActionSupport {
  
      private String cname;
  
      private List&lt;Category&gt; cl = new ArrayList&lt;Category&gt;();
  
  
      public List&lt;Category&gt; getCl() {
          return cl;
      }
  
      public void setCl(List&lt;Category&gt; cl) {
          this.cl = cl;
      }
  
      @Override
      public String execute() throws Exception {
  
          Session session = null;
          int c;
          //c store the cid of the selected Category name from drop down list.
          try {
              session = HibernateUtil.getSessionFactory().getCurrentSession();
              session.beginTransaction();
              cl = (List&lt;Category&gt;) session.createQuery("from Category c where c.name = '" + getName() + "'");
              if (!cl.isEmpty()) {
                  c = cl.get(0).getCid();
              } else {
                  this.addActionError("Oops. Sorry No Category Available.");
                  session.close();
                  return ERROR;
              }
  
              u = new Question();
              u.setCid(c);
              u.setCname(getName());
              session.save(u);
              session.getTransaction().commit();
          } catch (Exception e) {
              this.addActionError("Oops. An Error Encountered...! Email address already registered. Try with your new email address.");
              session.close();
              return ERROR;
          }
          return SUCCESS;
      }
  
  
      @Override
      public void validate() {
          if ("".equals(getEmail()) || getEmail() == null ) {
              this.addActionError("All Fields are Compulsory to input..!");
          } else if (getEmail().indexOf("@") &lt; 0 || getEmail().indexOf(",") &gt; 0 || getEmail().indexOf(".") &lt; 0) {
              this.addActionError("Please Input a valid email address.");
          }
      }
  }
  </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>