|
Guidelines, Patterns, and code for end-to-end Java applications.Questions and Answers - Platform Technologies1. How and where should session state be maintained? Client-server systems are defined by servers providing information services to clients. Usually, there are more clients than servers, so servers need a way to keep track of which client is which. A "session" is a single client's conversation (usually involving many request/response roundtrips) with a logical server (which may be formed of one or more physical servers). Session state is client-specific data that is accumulated during the session. For the purposes of this discussion, session state is any information relating to a particular user's interaction with a J2EE application in a single session. User name, user preferences, and shopping cart contents are all examples of session state in the Java Pet Store sample application. Originally, Web servers supported no concept of session or of session state. Since HTTP is a stateless protocol, the original HTTP servers maintained no information (other than logs) about each service request once the request was completed. As a result, users were indistinguishable from one another, and there was no way for a user to accumulate information over a series of service requests, for use in a subsequent transaction. As Web applications have become more sophisticated, several mechanisms for maintaining user sessions, and the state associated with them, have developed. Multitier Web applications may now store session state in one or more of the application tiers. Selecting the appropriate tier(s) for application state is a crucial choice in a design. The J2EE BluePrints application programming model defines applications in terms of several tiers. (The tiers and their relationships appear in "J2EE Platform Overview".) The tradeoffs involved in selecting a particular tier for storing session state are discussed in the "Questions and Answers" sections for each tier, and are summarized below:
| |||||
|
| ||||||||||||