You may be able to do this logic in the UserCounterListener since it
does something similar. Otherwise, I believe you have to register this
in a Spring XML file, rather than your web.xml.

Matt

On Thu, Sep 24, 2009 at 8:26 AM, sudhakargupta
<sudhakargupta_s...@hotmail.com> wrote:
>
> Hi Matt,
>
>  i need to update the login time when i logged into the application, i get
> a some sample code like this
>
> public class LoginListener implements ApplicationListener {
>
>    private UserManager userManager;
>    /**
>     * @param userManager the userManager to set
>     */
>    public void setUserManager(UserManager userManager) {
>        this.userManager = userManager;
>    }
>
>    /**
>    * @see
> org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
>    */
>    public void onApplicationEvent(ApplicationEvent event) {
>
>        System.out.println("outside....");
>        //   check failed event
>        if(event instanceof AuthenticationSuccessEvent) {
>            AuthenticationSuccessEvent authenticationSuccessEvent =
> (AuthenticationSuccessEvent) event;
>            String username =
> authenticationSuccessEvent.getAuthentication().getName();
>            HttpSession session = 
> ServletActionContext.getRequest().getSession();
>            session.setAttribute("user", 
> userManager.getUserByUsername(username));
>            User user = userManager.getUserByUsername(username);
>            user.setLastLoginTime(new Date());
>            System.out.println("inside....");
>            try {
>                System.out.println("outside try....");
>                userManager.saveUser(user);
>            } catch (UserExistsException e) {
>                e.printStackTrace();
>            }
>        }
>    }
> }
>
> registered it as listener in web.xml, but it is not working
>
> <listener>
>
> <listener-class>com.ozonetel.unitech.webapp.action.LoginTimeListener</listener-class>
> </listener>
>
> please provide me the solution for this one ...
>
>
>
>
>
> -----
> ---
> Sudhakar
> --
> View this message in context: 
> http://www.nabble.com/problem-with-Update-the-login-time-when-login-is-success-tp25572202s2369p25572202.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
> For additional commands, e-mail: users-h...@appfuse.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net

Reply via email to