Hi
Which one is best to use whether HttpSession/@SessionAttribute to user session?
please provide some steps/references to session tracking
Thanks in Advance
Hi
Which one is best to use whether HttpSession/@SessionAttribute to user session?
please provide some steps/references to session tracking
Thanks in Advance
Depends on what you want and what your usecase is.
Marten Deinum
Java Consultant / Pragmatist / Open Source Enthousiast / Author
Pro Spring MVC: With Web Flow
Conspect
Have you read the reference guide.
Use the [ code ] tags, young padawan
Please find the Use case
After the below code I need to Track session for the user "xxxSyed"
Thanks!Code:UserDetails userDetails= myUserService.loadUserByUsername(principal); //UserDetails userDetails= myUserService.loadUserByUsername("xxxSyed"); for (GrantedAuthority auth : userDetails.getAuthorities()) { } Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken(userDetails.getUsername(),""); authentication = authenticationManager.authenticate(token); // Setup the security context, aka authenticate SecurityContextHolder.getContext().setAuthentication(authentication); for (GrantedAuthority auth : SecurityContextHolder.getContext().getAuthentication().getAuthorities()) { System.out.println(auth.getAuthority()); } SecurityContextHolder.getContext().setAuthentication(authentication);
Apparently track the session is 100% clear for you but I still have no clue on what it is you want.
I also suggest a read of the reference guide especially the @SessionAttributes part. IN short @SessionAttributes can be used to store model attributes in between requests to the SAME controller not OVER controller or to store other session bound information. That is its sole usecase.
If you need something else use either a session-scoped object or put something in the session yourself.
That being said I want to repeat that I still have no clue what you want.
Marten Deinum
Java Consultant / Pragmatist / Open Source Enthousiast / Author
Pro Spring MVC: With Web Flow
Conspect
Have you read the reference guide.
Use the [ code ] tags, young padawan