public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { User loginData = (User) command;   User user = mgr.checkUser(loginData.getUsername()); if (user != null) {    user.setLastLogin(user.getCurrentLogin()); user.setCurrentLogin(new Date()); user = mgr.updateUser(user);   if (user.getUsername().equals(loginData.getUsername()) && user.getPassword().equals(loginData.getPassword())) {  UserSession userSession = new UserSession(user); request.getSession().setAttribute("userSession", userSession);  return new ModelAndView(new RedirectView(getSuccessView())); } }   errors.rejectValue("username", "login failed", null, getMessageSourceAccessor().getMessage("login.datanotok")); return showForm(request, response, errors);
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { User loginData = (User) command;    User user = mgr.checkUser(loginData.getUsername()); if (user != null) {    user.setLastLogin(user.getCurrentLogin()); user.setCurrentLogin(new Date()); user = mgr.updateUser(user);       if (user.getUsername().equals(loginData.getUsername()) && user.getPassword().equals(loginData.getPassword())) {  UserSession userSession = new UserSession(user); request.getSession().setAttribute("userSession", userSession);    return new ModelAndView(new RedirectView(getSuccessView())); }
		public ModelAndView onSubmit(HttpServletRequest request, 					HttpServletResponse response, 					Object command, BindException errors) 		throws Exception { 			User loginData = (User) command;			//if (request.getParameter("loginUsername") != null && request.getParameter("loginPassword") != null) { 				//user = mgr.checkUser(request.getParameter("loginUsername")); 				User user = mgr.checkUser(loginData.getUsername());				if (user != null) {				    //Roland Vecera				    //always store currentLogin Date				    //and move older one to lastLogin				    user.setLastLogin(user.getCurrentLogin());				    user.setCurrentLogin(new Date());				    user = mgr.updateUser(user);				    					//if (user.getUsername().equals(request.getParameter("loginUsername")) && user.getPassword().equals(request.getParameter("loginPassword"))) {					if (user.getUsername().equals(loginData.getUsername()) && user.getPassword().equals(loginData.getPassword())) {						// create session for user						UserSession userSession = new UserSession(user);						request.getSession().setAttribute("userSession", userSession);												return new ModelAndView(new RedirectView(getSuccessView())); 					}				}			//} 							errors.rejectValue("username", "login failed", null, getMessageSourceAccessor().getMessage("login.datanotok")); 				return showForm(request, response, errors); 			//return new ModelAndView(new RedirectView(getFormView()), "messageLogin",  getMessageSourceAccessor().getMessage("login.datanotok"));					}