I assume you are using spring security. After a successful login, put the UserDetails object in the session as follows (usually this is the controller that you would redirect to if the login was successful)
Object principal = SecurityContextHolder.getContext() .getAuthentication().getPrincipal(); HttpSession session = request.getSession(true); //create a new session // put the UserDetails object here. session.setAttribute("userDetails", principal);
In your JSP, you can access the UserDetails object, for example:
<span class="message">Welcome ${userDetails.username}</span>
source share