title: Dynamically change JSP page content without buttons
body: <p>I've written a code that dynamically fills a drop down list from an SQL database.
  Next, I need to change the content of the page depending on user selection in real-time (no buttons), perhaps show another label, or even show another drop down list that also gets it's values from an SQL DB depending on the previous selection etc..
  Here is my code</p>
  
  <pre><code>&lt;%@ page import="java.sql.*" %&gt;
  &lt;%ResultSet resultset = null;
  Connection conn;%&gt;
  &lt;HTML&gt;
  &lt;%
      try {
          Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
          conn = DriverManager.getConnection("jdbc:sqlserver://DESKTOP-O708F3G\\SQLEXPRESS;databaseName=master",
                  "user", "pswd");
  
          Statement statement = conn.createStatement();
  
          resultset = statement.executeQuery("select * from RTable");
  %&gt;
  &lt;h1&gt; Drop down list&lt;/h1&gt;
      &lt;select name="projectname"&gt;
          &lt;%  while (resultset.next()) {%&gt;
          &lt;option&gt;&lt;%= resultset.getString(2)%&gt;&lt;/option&gt;
          &lt;% } %&gt;
      &lt;/select&gt;
  &lt;%
      } catch (Exception e) {
          out.println("error"+e);
      }
  %&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>After all the selections are done, I will display a "submit" button that sends the selected data to a back-end servlet (I know how to do that once the button is there).</p>