Cukup buat Servlet baru (Hapus Servlet) dan berikan ID di url dan tangani di halaman jsp baru ...Anda dapat mengubah kode Anda seperti ini:
Indeks JSP:
<a href="DeleteServlet?id=<%=Integer.toString(person.getID())%>">Delete</a>
Hapus Servlet : Diperbarui
@WebServlet(name = "DeleteServlet", urlPatterns = {"/DeleteServlet"})
public class DeleteServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = Logger.getLogger(CurdOperationsImpl.class.getName());
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String ID = request.getParameter("id");
int id = Integer.parseInt(PersonId);
deleteClient(id); // add your own code
out.println("<h2 style='color: green'>Person Deleted Sucessfully.</h2>");
response.sendRedirect("index.jsp");
}else {
}
}
Bonus :dapatkan ini proyek Servlet-JSP-Mysql jelek saya siap digunakan Tautan Github Saya harap ini membantu Anda.