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.

Tip

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.