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

package Controller;

import Dao.CBSAccountMappingDao;
import DataEntryBean.ChequeDetailsBean;
import LoginDb.DbHandler;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
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 1004242
 */
public class privacyPolicyServlet extends HttpServlet{
  @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        HttpSession session = request.getSession(false);
        String pacsId = (String) session.getAttribute("pacsId");
        String tellerId = (String)session.getAttribute("user");
        Connection connection = null;
        Statement statement = null;
        
        if ( pacsId !=null && tellerId !=null) 
        {    
        
        try {
            connection = DbHandler.getDBConnection();
            statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(" insert into policy_log (policy_type, pacs_id, login_id, proc_date, proc_time) values \n" +
                "('PRIVACY', '"+ pacsId +"', '"+ tellerId +"', (select system_date from system_date), to_date(to_char(SYSTIMESTAMP, 'DD-MON-RRHH24:MI:SS'), 'DD-MON-RRHH24:MI:SS')) ");
            
        } catch (Exception e) {
            System.out.println("Error occurred during processing.");
        
        } 
        finally {
                try {
                    if(statement !=null)
                        statement.close();
                    if (connection != null)
                    connection.close();

                } catch (Exception e) {               
                    System.out.println("Error Occurred during connection close.");
                }
            request.getRequestDispatcher("/privacyPolicy1.jsp").forward(request, response);     
        }
        }
        
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
