clipped from: www.vaannila.com   

The execute method contains the business logic of the application. Here first we typecast the ActionForm object to LoginForm, so that we can access the form variables using the getter and setter methods. If the user name and password is same then we forward the user to the success page else we forward to the failure page.


public class LoginAction extends org.apache.struts.action.Action {
02. 
03.    private final static String SUCCESS = "success";
04.    private final static String FAILURE = "failure";
05. 
06.    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
07.        LoginForm loginForm = (LoginForm) form;
08.        if (loginForm.getUserName().equals(loginForm.getPassword())) {
09.            return mapping.findForward(SUCCESS);
10.        } else {
11.            return mapping.findForward(FAILURE);
12.        }
13.    }
14.}