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


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


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
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 ValidateDelete extends HttpServlet {
   
   
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try 
        {
           String username=request.getParameter("username");
           String password=request.getParameter("password");
      
		   DataBase checkuser=new DataBase();
           boolean isValid = checkuser.validateUser(username, password);
        
                   if(isValid)
			{
		   
		   
		   
               request.setAttribute("username",username);
               RequestDispatcher rd = request.getRequestDispatcher("delete.jsp");
               rd.forward(request, response);
               HttpSession session =request.getSession();
               session.setAttribute("username", username);
               session.setAttribute("password",password);
               
              }
            
      else
           {
               request.setAttribute("error","username/password is invalid");
               RequestDispatcher rd = request.getRequestDispatcher("dlogin.jsp");
               rd.forward(request, response);
               
           } 




	   
	  
		}
        catch(Exception e)
        {
            out.print(e);
        }
        finally { 
            out.close();
        }
    } 

}
