title: Retrive id and delete query using button in jsp
body: <p>Friends i have a jsp page which retrieves data from sql table and displays them in form of table. I will also display another column consisting of a button to delete that row/entry from the sql table.
  Following is the code for my jsp page:</p>
  
  <pre><code> &lt;%@ page import="java.sql.*" %&gt;
      &lt;%
              Class.forName ("com.mysql.jdbc.Driver");            
              Connection  conn=null;  
              conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/demo","root","pass");
              %&gt;
      &lt;body&gt;
      &lt;center&gt;
          &lt;h1&gt;USERS TABLE&lt;/h1&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;th&gt;UserId&lt;/th&gt;
                  &lt;th&gt;Username&lt;/th&gt;
              &lt;/tr&gt;
          &lt;%
              Statement stm = conn.createStatement();
              String s = "SELECT * FROM login";
              ResultSet r = stm.executeQuery(s);
              while ( r.next() )
               { 
                   out.print("&lt;tr&gt;");
                   out.print("&lt;td&gt;" +  r.getString ("userid") + "&lt;/td&gt;" ); 
                   out.print("&lt;td&gt;" +  r.getString ("username") + "&lt;/td&gt;");
                   out.print("&lt;td&gt;" +  "&lt;input type=button value='Delete'/&gt;"+ "&lt;/td&gt;");
                   out.print("&lt;/tr&gt;");
               }
           %&gt;     
          &lt;/table&gt;
      &lt;/center&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>Now i want my delete button to extract the userid and pass a query to delete the selected user from the database. I am just confused about how to achieve this userid extraction and process the query.</p>