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


import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class DeleteProductServlet extends HttpServlet {

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
DBManager db=new DBManager();
Connection conn=db.getConnection();
Statement stmt=conn.createStatement();

ResultSet rs=null;
String id=request.getParameter("id");
out.println(id);

int result= stmt.executeUpdate("DELETE FROM TBL_PRODUCTS WHERE ID=+'"+id+"'+");
//int result=stmt.executeUpdate(sql);

if(result==1)
{
out.println("Delete data sucessfully");
}
else if (result!=1)
{
out.println("Delete data unsucessful");
}

} finally {
out.close();
}
}
}