/*
 * ValidarAction.java
 *
 * Created on 6 de noviembre de 2007, 13:12
 */

package servlets;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import modelo.*;
import javabeans.*;
public class ValidarAction extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        String driver=this.getServlet().getServletContext().getInitParameter("driver");
        String cadenaCon=this.getServlet().getServletContext().getInitParameter("cadenaCon");
        GestionClientes gc=new GestionClientes(driver,cadenaCon);
        ValidacionForm vf=(ValidacionForm)form;
        if(gc.validar(vf)){
            return mapping.findForward("bienvenida");
        }
        else{
            vf.setMensaje("<h2>Combinación de usuario y password incorrecta!</h2>");
            return mapping.findForward("error");
        }
        
    }
}
