title: arraylist to select an option in jsp
body: <p>How to assign an arraylist to select an option in jsp? I found an example(<a href="https://stackoverflow.com/questions/19293792/how-to-assign-arraylist-to-select-option-in-jsp">how to assign arraylist to select option in jsp</a>) but still get empty options.</p>
  
  <pre><code>IndexServlet.java
  
  @WebServlet("/IndexServlet")
  public class IndexServlet extends HttpServlet {
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          List&lt;String&gt; databaseArrayList = new ArrayList();
          databaseArrayList.add("1");
          databaseArrayList.add("2");
          databaseArrayList.add("3");
          request.setAttribute("databaseList", databaseArrayList);
          request.getRequestDispatcher("AddManager.jsp").forward(request, response);
          System.out.println("in index servlet");
  }
  }
  </code></pre>
  
  <p>JspCode</p>
  
  <pre><code>&lt;tr&gt;
              &lt;td&gt;Subordinate employees:&lt;/td&gt;
              &lt;td&gt;
                  &lt;select name="database1"&gt;
                      &lt;c:forEach items="${databaseList}" var="databaseValue"&gt;
                          &lt;option value="${databaseValue}"&gt;
                                  ${databaseValue}
                          &lt;/option&gt;
                      &lt;/c:forEach&gt;
                  &lt;/select&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  </code></pre>