I add some code for autologin after register. this is the code

UserDetails userDetails = userDetailsService.loadUserByUsername(username);
Authentication authentication = new PrincipalSpringSecurityUserToken(username,
username, userDetails.getPassword(), userDetails.getAuthorities(), userDetails);

// Place the new Authentication object in the security context.
SecurityContextHolder.getContext().setAuthenticati on(authentication);

I use security tag to show username after login. but username do not appear. who can tell me, what wrong.
thanks in advances