title: how to delete single recodrs from multiple row records like gridview in jsp page
body: <p>I am trying to edit and delete a single record from multiple records.Here below is my sample record displaying on jsp page,</p>
  
  <p><img src="https://i.stack.imgur.com/suJMS.png" alt="enter image description here"></p>
  
  <p>I can edit the record for each row easily using below code,</p>
  
  <pre><code>  &lt;%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%&gt;
           &lt;%@ page import="java.util.List" %&gt;
            &lt;%@ page import="java.util.Iterator" %&gt;
  
       &lt;%@page import="java.sql.ResultSet"%&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=UTF-8"&gt;
      &lt;title&gt;Insert title here&lt;/title&gt;
      &lt;script src="jquery1.11.0.min.js"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;script type="text/javascript"&gt;
  
  
                  function editRecording(task_id) {
                      //alert(task_id)
  
                              url = "EditRecord";
                              window.location="/RTTSchecking/"+url+"?task_id="+task_id;
  
                      }
  
  
          &lt;/script&gt;
  
    &lt;table align="center" border="1px" width="80%"  &gt;
      &lt;thead&gt;
          &lt;tr&gt;
          &lt;th&gt;User_Id&lt;/th&gt;
          &lt;th&gt;Class&lt;/th&gt;
          &lt;th&gt;Subject&lt;/th&gt;
          &lt;th&gt;Chapter&lt;/th&gt;
          &lt;th&gt;Planned_Features&lt;/th&gt;
          &lt;th&gt;Planned_Date&lt;/th&gt;
  
      &lt;/thead&gt;
  
  
              &lt;%Iterator itr;%&gt;       
              &lt;%List data = (List) request.getAttribute("TaskData");
  
              for(itr = data.iterator(); itr.hasNext();)
              {
                  %&gt;
                  &lt;tr&gt;
                  &lt;% String s = (String) itr.next(); 
                  %&gt;
                  &lt;td style="background-color: yellow;"&gt;
                  &lt;input type="text" name="tid" value="&lt;%=s %&gt;"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="tid" value="&lt;%=itr.next() %&gt;"&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;%=itr.next() %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=itr.next() %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=itr.next() %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%=itr.next() %&gt;&lt;/td&gt;
  
  
                  &lt;td&gt;&lt;input type="button"  value="edit" name="&lt;%=s%&gt;" onclick="editRecording(this.name);"&gt;&lt;/td&gt; 
               &lt;td&gt;&lt;input type="button"  value="delete" name="&lt;%=s%&gt;" onclick="deleteRecording(this.name);"&gt;&lt;/td&gt; 
  
  
  
                  &lt;% } %&gt;
  
  
  
                  &lt;/tr&gt;
  
                  &lt;/table&gt;
  
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p><strong>EditREcord(servlet):</strong></p>
  
  <pre><code>public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
          PrintWriter out = response.getWriter();
  
          try {
  
              String a=request.getParameter("task_id");
  
          convty = new Connectivity();
          con = convty.setConnection();
          st = con.createStatement();
          query = "select * from task_table where task_id='"+a+"'";
          rset = convty.getResultSet(query, con);
  
  
          }
          catch(Exception e) {
  
          }
          finally {
              request.setAttribute("EditData", rset);
              RequestDispatcher dd= request.getRequestDispatcher("editdata.jsp");
              dd.forward(request, response);
              out.close();
              //out.println(""+tid);
          }
  
      }
  </code></pre>
  
  <p>Above code working fine.But my problem is, i want to delete record based on User_id, Class, Subject, Chapter and Planned_Date so how can i get these values from single row (which want to delete row)?</p>
  
  <p>how to achive this below code?,</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
  
  
                          function deleteRecording(User_id,Class,Subject,Chapter,Date) {
                              //alert(task_id,Class,Subject,Chapter,Date)
  
                                      url = "EditRecord";
                                      window.location="/RTTSchecking/"+url+"?user_id="+User_id+"&amp;Tclass="+Class+"&amp;subject="+Subject+"&amp;chapter="+Chapter+"&amp;date="+Date;
  
                  &lt;/script&gt;
  </code></pre>
  
  <p>once if i achieved above code then i can easily delete selected single record from multiple rows using below code,</p>
  
  <pre><code>try {
  
                  String uid=request.getParameter("user_id");
  String class=request.getParameter("Tclass");
  String sub=request.getParameter("subject");
  String chap=request.getParameter("chapter");
  String date=request.getParameter("date");
  
              convty = new Connectivity();
              con = convty.setConnection();
              st = con.createStatement();
              query = "delete from task_table where User_id='"+uid+"' and class='"+class+"' and subject='"+sub+"' and chapter='"+chap+"' and date='"+date+"'";
             st.executeUpdate(query);
  
  
              }
              catch(Exception e) {
  
              }
  </code></pre>
  
  <p><strong>Note :</strong> I can do delete records using <strong>delete from task_table where User_id='"+uid+"';</strong></p>
  
  <p>but how to do with  <strong>query = "delete from task_table where User_id='"+uid+"' and class='"+class+"' and subject='"+sub+"' and chapter='"+chap+"' and date='"+date+"'";</strong></p>
  
  <p>I hope someone will help me out.</p>