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


import com.sun.org.apache.bcel.internal.classfile.Code;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Varun
 */
public class CancelMeetings extends HttpServlet {
   
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try{
        Connection conn = DataBase.getConnection();
        Statement st = conn.createStatement();
        HttpSession sess = request.getSession();
        String s = (String)sess.getAttribute("id");
        String s1 = (String)sess.getAttribute("meetingAgenda");
        System.out.print(s+s1);
        
        
        
        
        
        String q = "select agenda from sdms.scheduledmeetings where empid ="+s+" and agenda = '"+s1+"' and status = 5";
     
        ResultSet rs = st.executeQuery(q);
        while(rs.next())
        {
            String a = rs.getString("agenda");
            
            st.executeUpdate("delete from sdms.scheduledmeetings where agenda = '" + a+ "'");
            
        }
        
        
       
                
        
        
        }
       catch(Exception e)
       {
       
       }
         response.sendRedirect("CancelConfirmation.jsp");
        
    } 

   
}
