title: how to load values in dropdown using jstl
body: <p>I am searching a way to populate a dropdown using jstl. I need to do this when page is loading. I tried some code. But it is not working. 
  <br/></p>
  
  <pre><code>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;  
   &lt;select&gt;
           &lt;c:forEach items="${requestScope.personList}"  var="person"&gt;
           &lt;option value="${person.getId()}"&gt;${person.getName()}
           &lt;/option&gt;
           &lt;/c:forEach&gt;
   &lt;/select&gt;
  </code></pre>
  
  <p>And this is my controller servlet code. 
  <br/></p>
  
  <pre><code>    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      response.setContentType("text/html;charset=UTF-8");
      try {
          CasualLeaveService service1 = new CasualLeaveServiceImpl();
          List&lt;Person&gt; personList = service1.searchName();
          request.setAttribute("personList", personList);
          RequestDispatcher rd = getServletContext().getRequestDispatcher("/casual");
          rd.forward(request, response);
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p><br/>
  <br/>
  This is my server class code. 
  <br/></p>
  
  <pre><code>public List&lt;Person&gt; searchName() {
      List&lt;Person&gt; list = null;
      try (DaoSession session = DaoSessionFactory.createSession()) {
          EmployeeDao emp = session.getEmployeeDao();
          list = emp.findAllPersons();
          if (!list.isEmpty()) {
              System.out.println("My list is :"+list);
          } else {
              System.out.println("Error in list");
          }
      }
      return list;
  }
  </code></pre>
  
  <p><br/>
  My Person class
  <br/></p>
  
  <pre><code>    public class Person {
  
  private int id;
  private String employeeNo;
  private String name;
  
  @ValidNo(message = "Must be a number between 1 to 999")
  private Integer epfNo;
  
  public Person() {
  }
  
  /**
   *
   * @param id
   * @param employeeNo
   * @param name initials + surname
   * @param epfNo
   */
  public Person(int id, String employeeNo, String name, Integer epfNo) {
      this.id = id;
      this.employeeNo = employeeNo;
      this.name = name;
      this.epfNo = epfNo;
  }
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  public String getEmployeeNo() {
      return employeeNo;
  }
  
  public void setEmployeeNo(String employeeNo) {
      this.employeeNo = employeeNo;
  }
  
  /**
   *
   * @return initials + surname
   */
  public String getName() {
      return name;
  }
  
  /**
   *
   * @param name initials + surname
   */
  public void setName(String name) {
      this.name = name;
  }
  
  public Integer getEpfNo() {
      return epfNo;
  }
  
  public void setEpfNo(Integer epfNo) {
      this.epfNo = epfNo;
  }
  
  @Override
  public int hashCode() {
      int hash = 7;
      hash = 67 * hash + this.id;
      return hash;
  }
  
  @Override
  public boolean equals(Object obj) {
      if (obj == null) {
          return false;
      }
      if (getClass() != obj.getClass()) {
          return false;
      }
      final Person other = (Person) obj;
      return this.id == other.id;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><br/>
  My Web.xml is mapped like this. 
  <br/></p>
  
  <pre><code>&lt;servlet&gt;
      &lt;jsp-file&gt;/WEB-INF/views/leave/CasualLeave.jsp&lt;/jsp-file&gt;
      &lt;servlet-name&gt;casualLeave&lt;/servlet-name&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;casualLeave&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/casual&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I can assure that service class is working perfectly fine. Because I just called this service class method directly to jsp and output is coming perfectly. The problem is using jstl this methods are not working. 
  <br/>
  Can you tell me what is the error. Because I don't like to use scriptlet tags within jsp html code. I heard it is bad practice. 
  <br/>
  Thank you.</p>