/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
/**
 *
 * @author eworld_6
 */
public class DeletingProcess extends HttpServlet {
   
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            String command = request.getParameter("cmd");
            String serial=request.getParameter("serial");
            DataBase dbc= new DataBase();
          if(command.equalsIgnoreCase("Delete"))             
          {
                int k=Integer.parseInt(serial);
               boolean b=dbc.delete(k);
if(b)
			  { request.setAttribute("insert","Deleted Successfully");
                RequestDispatcher rd=request.getRequestDispatcher("delete.jsp");
                rd.forward(request, response);
			  }
				else
			  {
					request.setAttribute("error","Not Found");
                RequestDispatcher rd=request.getRequestDispatcher("delete.jsp");
                rd.forward(request, response);
			  }
                    
          }
		}          
            
       catch(Exception e){out.println(e);}
        finally { 
            out.close();
        }
    } 
     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
    * Returns a short description of the servlet.
    */
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
