FileDocCategorySizeDatePackage
LoginAction.javaAPI DocExample1629Sun Aug 15 23:02:16 BST 2004com.oreilly.strutsckbk.ch09

LoginAction

public class LoginAction extends org.apache.struts.action.Action

Fields Summary
Constructors Summary
Methods Summary
public org.apache.struts.action.ActionForwardexecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        
        ActionMessages messages = new ActionMessages();
        
        String username = (String) PropertyUtils.getSimpleProperty(form, "username");
        String password = (String) PropertyUtils.getSimpleProperty(form, "password");
                
        SecurityService service = new SecurityService();
        service.authenticate( username, password);

        User user = new User();
        user.setUsername(username);
        request.getSession().setAttribute("user", user);
        
        ActionMessage message = new ActionMessage("message.login.success", username);

        messages.add(ActionMessages.GLOBAL_MESSAGE, message);

        if (!messages.isEmpty()) {
            saveMessages( request.getSession(true), messages );
        }

        return mapping.findForward("success");