Many applications require a series of requests from a client to be associated with one another.
For example, the Duke's Bookstore application saves the state of a user's shopping cart across requests. Web-based applications are responsible for maintaining such state, called a session , because the HTTP protocol is stateless. To support applications that need to maintain state, Java Servlet technology provides an API for managing sessions and allows several mechanisms for implementing sessions. Accessing a Session Sessions are represented by an HttpSession object. You access a session by calling the getSession method of a request object.