package userstruts;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.Action;

public class LoginAction
    extends Action {
  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest servletRequest,
                               HttpServletResponse servletResponse) {
    UserActionForm userActionForm = (UserActionForm) actionForm;
    String username = userActionForm.getUserName();
    String password = userActionForm.getPassword();
    UserBean user = new UserBean();
    boolean flag = user.verifyUser(username, password);
    if (flag) {
      return actionMapping.findForward("success");
    }
    else {
      return actionMapping.findForward("error");
    }
  }
}
