Placing the profile in a session

The next thing we want is the profile to be stored in a session so that it does not get reset every time we go on the profile page. This can apparently prove tiresome to some users and we have to address it.


HTTP sessions are a way to store information between requests. HTTP is a stateless protocol, which means that there is no way to relate two requests coming from the same user. What most Servlet containers do is they associate a cookie called JSESSIONID to each user. This cookie will be transmitted in the request header and will allow you to store arbitrary objects in a map, an abstraction called HttpSession. Such a session will typically end when the user closes or switches web browsers or after a predefined ...

Get Spring MVC: Designing Real-World Web Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.