25. Managing User Session Data

PROBLEM

If session-scoped components aren't managed properly, there is a potential for a lot of user session data being maintained by an application server, putting a strain on application server resources and limiting the scalability of a web application. Therefore there needs to be a strategy managing session scoped variables. While Servlet specification has a mechanism for clearing a user's session, it doesn't allow you to selectively discard session data. For example you may want to remove certain components from the user session while retaining other components.

SOLUTION

The Clear Component step lets a developer discard a model from a session. This allows a developer to use session-scoped components when needed and selectively discarding the model when no longer needed.

HOW IT WORKS

In navigating the functionality of an application, an end-user may interact with a variety of different session-scoped Components. If the session isn't properly managed by an application, all component data would stored in the session, even component data that is no longer needed. A developer can selectively discard components from a session using the Clear Component step.

RELATED RECIPES

  1. Defining the Scope of Components