title: How to reload my <select> element from a database in Java
body: <p>I have submitted some data in database from an html form. Then I have to load one column of that data in a <code>&lt;select&gt;</code> of another form. I have done this but how will I increase the number of options as the number of records is increased?</p>
  
  <p>Code is as follows:</p>
  
  <pre><code>&lt;%@ page import="java.util.*"%&gt;  
  &lt;%@ page import="java.lang.*"%&gt; 
  
  &lt;%!
      ArrayList al;
      Object o[];
      String s[] = new String[10];
  %&gt;
  
  &lt;jsp:useBean id="c" class="com.ebbeans.ViewBean"/&gt;
  &lt;jsp:setProperty name="c" property="*"/&gt;
  
  &lt;% 
      al = c.loadExistingEmpCode();
      o = al.toArray();
  
      for (int i = 0; i &lt; o.length; i++) {
          s[i] = (String) o[i];
      }  
  %&gt;
  
      ..........
      ..........
  
          &lt;select name="empCode" size="1" id="empCode"&gt;
              &lt;option value="&lt;%= s[0] %&gt;" selected&gt;&lt;%= s[0] %&gt;&lt;/option&gt;
              &lt;option value="&lt;%= s[1] %&gt;"&gt;&lt;%= s[1] %&gt;&lt;/option&gt;
              &lt;option value="&lt;%= s[2] %&gt;"&gt;&lt;%= s[2] %&gt;&lt;/option&gt;
              &lt;option value="&lt;%= s[3] %&gt;"&gt;&lt;%= s[3] %&gt;&lt;/option&gt;
              &lt;option value="&lt;%= s[4] %&gt;"&gt;&lt;%= s[4] %&gt;&lt;/option&gt;
          &lt;/select&gt;
  </code></pre>
  
  <p>Here only 5 options will be shown. How would I increase the number of options dynamically when the records are incresed?</p>