Fair enough. But where are you displaying the output? Is this AWT/Swing based program, is this a web application? You can't display any formatted text in console.
Try to access this page without logging in or from a different browser after logging in.
In the above line we are retrieving the userinfo from session. If the value is not null we show the page. It will be not null only when the user comes to this page after logging in because there only you are setting the user info in session, if the url is opened from any different browser instance it will be null.