title: Populating a jsp drop-down menu with the values present in database
body: <p>How to populate a drop-down menu in JSP with the values present in the database (following MVC architecture) ?
  Tried doing this 
  Inside 
  EmployeeDAO.java</p>
  
  <pre><code>private List&lt;EmployeeVO&gt; empIDList;
  
      public List&lt;EmployeeVO&gt; getStateList(){
          empIDList=new ArrayList&lt;EmployeeVO&gt;();
          Connection con=DBUtil.getConnection();
  
  
  
          try {
              Statement stmt=con.createStatement();
              ResultSet rs=stmt.executeQuery("select Emp_id from Employee order by Emp_id ASC");
              while(rs.next()){
                  String emID=rs.getString("Emp_id");
                  int empID=Integer.parseInt(emID);
                  EmployeeVO s=new EmployeeVO();
                  s.setEmp_id(empID); 
                  empIDList.add(s);
              }
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
  
          }
          return empIDList;
      }
  </code></pre>
  
  <p>Inside 
  EmployeeVO.java</p>
  
  <pre><code>private int Emp_id;
      private String Emp_pwd;
      private String Emp_fname;
      private String Emp_mname;
      private String Emp_lname;
      private String Emp_dob;
      private String Emp_doj;
      private String Emp_status;
      public int getEmp_id() {
          return Emp_id;
      }
      public void setEmp_id(int emp_id) {
          Emp_id = emp_id;
      }
  </code></pre>
  
  <p>Inside 
  Employee.jsp</p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;jsp:useBean id="emplID" scope="session" class="com.model.EmployeeVO" /&gt;
  
  &lt;th&gt;Employee ID&lt;/th&gt;
                      &lt;td&gt;&lt;input type="text" name="EID" id="eid" /&gt; 
                      &lt;select
                          id="testlist"&gt;
                              &lt;c:forEach var="item" items="${emplID.items}"&gt;
                                  &lt;option&gt;${item}&lt;/option&gt;
                              &lt;/c:forEach&gt;
                      &lt;/select&gt; 
                      &lt;/td&gt;
  </code></pre>
  
  <p>The source code for the jsp was taken from <a href="https://stackoverflow.com/questions/2901222/populate-jsp-dropdown-with-database-info">this</a> page</p>