title: load values from database to combo box dynamically
body: <p>I am new to jsp and currently working in a simple project.</p>
  
  <p>In that project I need to load values from database to combo box dynamically.</p>
  
  <p>I followed some questions and answers from the web and from stackoverflow also, and found a way to do that.</p>
  
  <p>The only difference is, in that all cases they have used  <code>sun.jdbc.odbc.JdbcOdbcDriver</code>, but I am using <code>com.mysql.jdbc.Driver</code>. </p>
  
  <p>When I run my example it does not work, it does not even show the error.  Here is my code.</p>
  
  <pre><code>&lt;%@ page import="java.sql.*"%&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Combo Box&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;Select One&lt;/legend&gt;
          &lt;select id="projectName" class="col-sm-12 selectBox"&gt;
              &lt;option value="tttt"&gt;-Select-&lt;/option&gt;
  
              &lt;%
                  Connection con = null;
                  ResultSet rs = null;
  
                  try {
                      Class.forName("com.mysql.jdbc.Driver");
                      con = DriverManager.getConnection(
                              "jdbc:mysql://localhost:3306/new_dbpms", "root",
                              "12345");
                  } catch (Exception ex) {
                      out.println("exxx " + ex);
                  }
                  try {
                      PreparedStatement pst = con
                              .prepareStatement("select projectname from project where branchid=1");
                      //pst.setString(1,uid);
                      rs = pst.executeQuery();
                      while (rs.next()) {
                          String name = rs.getString("name");
              %&gt;
              &lt;option value="&lt;%=name%&gt;"&gt;&lt;%=name%&gt;&lt;/option&gt;
              &lt;%
                  }
                  } catch (Exception e) {
                      out.print("error: " + e);
                  }
              %&gt;
  
          &lt;/select&gt;
  
      &lt;/fieldset&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can you please explain me what is the error here and a way to overcome the issue.
  Thank you !!</p>