title: how to submit the option selected from drop down list in jsp page to perform a mysql query
body: <p>My project is StaffAllocation, and I want to retrieve information from the database. I'm very new and this is my very first project. I created a drop down list retrieving <code>staffnames</code> from one of my table. Now I want to perform a query action to view the details of the selected <code>staffnames</code> from the drop-down list. The following is the coding which i have, which is not correct:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%&gt;
    &lt;%@ page import="java.sql.*" %&gt;
    &lt;%@ page import="java.io.*" %&gt;
    &lt;%@ page import="java.lang.*" %&gt;
    &lt;%@ page import="javax.servlet.*" %&gt;
    &lt;%@ page import="javax.servlet.http.*" %&gt;
    &lt;%ResultSet resultset =null; %&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;Staff Details&lt;/title&gt;
    &lt;/head&gt;
    &lt;BODY&gt;
    &lt;form method=post&gt;
    &lt;h3&gt;Select Stafftype:&lt;/h3&gt;
    &lt;p&gt;&lt;input type="radio" name="Stafftype" value="Male"&gt; Male&lt;/input&gt;&lt;/p&gt;
    &lt;p&gt;&lt;input type="radio" name="Stafftype" value="Female"&gt; Female&lt;/input&gt;&lt;/p&gt;
    &lt;input type="submit" value="Submit"&gt;
    &lt;/form&gt;
    &lt;%
    try{
  
      Class.forName("com.mysql.jdbc.Driver");
      Connection connection =      DriverManager.getConnection("jdbc:mysql://localhost:3306/StaffAllocation?  user=root&amp;password=success");
      Statement statement = connection.createStatement() ;
      String Stafftype= request.getParameter("Stafftype");
      out.print(Stafftype);
      if(Stafftype.contentEquals("Male")){
      resultset=statement.executeQuery("select * from tblstaffdetails where Stafftype=  'Male'");
      }
      else if(Stafftype.contentEquals("Female")){
          resultset=statement.executeQuery("select * from tblstaffdetails where   Stafftype= 'Female'");
      }
      else
      {
          System.out.println("your coding is wrong");
      }
     %&gt;
  
      &lt;select&gt; &lt;% while(resultset.next()){ %&gt;
      &lt;option&gt;&lt;%= resultset.getString(2)%&gt;&lt;/option&gt;
     &lt;%} %&gt; 
  
     &lt;%
  
     String StaffName= request.getParameter("StaffName"); 
     int staffId;
     String subcode;
     if(StaffName != null) {
     resultset=statement.executeQuery("SELECT a.staffId, a.StaffName, b.subcode FROM tblstaffdetails a LEFT JOIN tblsubhandled b ON a.staffId = b.staffId where StaffName='request.getParameter('StaffName')'");
  
       }       
       }
      catch(Exception e)
      {
           out.println("wrong entry"+e);
      }
      %&gt;
     &lt;form method = "get"&gt;
     &lt;br&gt;&lt;br&gt;
     &lt;input name="Submit" type="button" value="Submit"&gt;
     &lt;/form&gt;
     &lt;/body&gt;
     &lt;/html&gt;`
  </code></pre>
  
  <p>Tables:</p>
  
  <p>tblstaffdetails -(1).staffId(2).StaffName(3).Stafftype(male or female)</p>
  
  <p>tblsubhandled - (1).staffId(2).subcode</p>