protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id = request.getParameter("id"); String firstname = request.getParameter("firstname"); String lastname = request.getParameter("lastname"); String phone = request.getParameter("phone"); String email = request.getParameter("email"); String attendance = request.getParameter("attendance"); String photo = request.getParameter("upload"); String insert = request.getParameter("insert"); StudDao sd = new StudDao(); List<Student> list = sd.select(); request.setAttribute("List", list); if (ServletFileUpload.isMultipartContent(request)) { // System.out.println("file Uploading"); RequestDispatcher rd = request.getRequestDispatcher("/StudentUpload"); rd.forward(request, response); } if (insert != null && insert != "") { sd.insert(firstname, lastname, email, attendance, photo, phone, Integer.parseInt("enroll")); list = sd.select(); request.setAttribute("List", list); response.sendRedirect("Student/form"); } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id = request.getParameter("id"); StudDao sd = new StudDao(); if (request.getParameter("delete") != null && request.getParameter("delete") != "" && request.getParameter("delete").equals("trash")) { System.out.println("delete operation"); sd.delete(Integer.parseInt(id)); List list = sd.select(); request.setAttribute("List", list); response.sendRedirect("Student/form"); } }