title: JSP dynamic dropdownlist
body: <p>I need to fill the dropdownlist according to selected field in another dropdownlist.How can i implement this? Here is my code :</p>
  
  <pre><code>                &lt;tr&gt;
                  &lt;td&gt;CITY :&lt;/td&gt;
                  &lt;td&gt;&lt;select name="city"&gt;
                          &lt;%
                              while (rs.next()) {
                          %&gt;
                          &lt;option value="&lt;%=rs.getString(1)%&gt;"&gt;&lt;%=rs.getString(1)%&gt;&lt;/option&gt;
                          &lt;%
                              }
                          %&gt;
                  &lt;/select&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;%
              rs = db.runQuery(conn, "Select distinct town from adress where city='" + request.getParameter("city") +"'");
              %&gt;
              &lt;tr&gt;
                  &lt;td&gt;TOWN&lt;/td&gt;
                  &lt;td&gt;&lt;select name="town"&gt;
                          &lt;%
                              while (rs.next()) {
                          %&gt;
                          &lt;option value="&lt;%=rs.getString(1)%&gt;"&gt;&lt;%=rs.getString(1)%&gt;&lt;/option&gt;
                          &lt;%
                              }
                          %&gt;
                  &lt;/select&gt;
              &lt;tr&gt;
  </code></pre>
  
  <p>First dropdown fills correctly but second one does not work.How can i handle this?</p>