title: Deleting table row using jsp and servlet
body: <p>Hello everyone hope you having a good day,because i'm not xD , i'm new to the web programming and i've started with JSP and Servelts to do web operation my problem is when i click on "delete" it triggers the servlet but nothing happen the row doesn't get deleted and the value ( pw.print(name) ) doesn't show up. these are my codes.</p>
  
  <p><strong>DeleteServlet.java</strong></p>
  
  <pre><code>import java.io.IOException;
  import java.io.PrintWriter;
  import java.sql.Connection;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  public class deleteuser extends HttpServlet {
  
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      PrintWriter pw=response.getWriter();
      try {
  
          Connection con=Connecter.obtenirconnexion();
          Statement st=con.createStatement();
          String name=request.getParameter("id");
          String Query="delete from users where name ='"+ name+"'";
          st.executeUpdate(Query);
          pw.print(name);
  
  
      } catch (SQLException ex) {
          Logger.getLogger(deleteuser.class.getName()).log(Level.SEVERE, null, ex);
      }
       request.getRequestDispatcher("users.jsp").forward(request, response);
  
  
  }
  @Override
  public String getServletInfo() {
      return "Short description";
  }// &lt;/editor-fold&gt;
  
  }
  </code></pre>
  
  <p><strong>Users.jsp</strong></p>
  
  <pre><code>&lt;%@page import="java.sql.ResultSet"%&gt;
  &lt;%@page import="java.sql.PreparedStatement"%&gt;
  &lt;%@page import="login.Connecter"%&gt;
  &lt;%@page import="java.sql.Connection"%&gt;
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;Users&lt;/title&gt;
      &lt;style&gt; table,td,th
          {
              border:1px black solid;
          } &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Hello World&lt;/h1&gt;
      &lt;%
          Connection con = Connecter.obtenirconnexion();
          String req = "select * from users";
          PreparedStatement pst = con.prepareStatement(req);
          ResultSet cur = pst.executeQuery();
          out.println("&lt;table &gt;&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Password &lt;/th&gt;&lt;th&gt;Rank         &lt;/th&gt;&lt;th&gt;Delete &lt;/th&gt;");
          while (cur.next()) {
              out.println("&lt;tr&gt;&lt;td&gt;" + cur.getString(1) + "&lt;/td&gt;&lt;td&gt;" + cur.getString(2) + "&lt;/td&gt;&lt;td&gt;" + cur.getString(3) + "&lt;/td&gt;&lt;td&gt; &lt;a href=deleteuser id='"+cur.getString(1)+"'&gt; delete &lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;");
          }
          out.println("&lt;/table&gt;");
          out.close();
      %&gt;       
  &lt;/body&gt;
  </code></pre>
  
  <p></p>