Chapter 2: Session tracking
The conversation between the browser and the web server in a web application is stateless since its protocol, HTTP, is stateless. For example, when a user is browsing through a catalog, the browser sends a separate request for each click on the catalog product and the web server sends a separate response with the requested product items. In this conversation, the web server is not aware of any previous request and response data, and does not keep any state.
The HttpSession mechanism is a set of classes that you get as part of the Servlet API. It contains the HttpSession class and other important classes such as HttpSessionListener and HttpSessionEvent. When you use HttpSession as your session tracking mechanism, it can become one of the bottlenecks in your application if not used efficiently. In this chapter, you'll find the following recipes that show how to implement HttpSession tracking efficiently. And you'll also find interesting internal details about HttpSession when you go through these recipes.
Reducing memory usage by programmatically removing HttpSession objects
Configuring appropriate session timeout value to efficiently remove HttpSession objects from memory
Minimizing the size of HttpSession objects to increase efficiency of your web application
This chapter discusses the following recipes to solve these issues when you design a web application.