package test.struts;

import javax.servlet.http.*;
import org.apache.struts.action.*;

public class LoginAction extends Action {

	public LoginAction() {}

	public ActionForward perform(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws java.io.IOException, javax.servlet.ServletException{

		LoginBean lb = new LoginBean();
		request.setAttribute("LoginBean", lb);
		lb.setParameters(request);
		ActionErrors ae = lb.validate();
		request.setAttribute(Action.ERROR_KEY, ae);

		if (ae == null || ae.size() == 0) {
			return mapping.findForward("valid");
		} else {
			return mapping.findForward("invalid");
		}
	}
}