Chapter 6. Session Management: Conversational state

image with no caption

Web servers have no short-term memory. As soon as they send you a response, they forget who you are. The next time you make a request, they don’t recognize you. In other words, they don’t remember what you’ve requested in the past, and they don’t remember what they’ve sent you in response. Nothing. Sometimes that’s fine. But sometimes you need to keep conversational state with the client across multiple requests. A shopping cart wouldn’t work if the client had to make all his choices and then checkout in a single request. You’ll find a surprisingly simple solution in the Servlet API.

OBJECTIVES

Session Management

4.1

Write servlet code to store objects into a session object and retrieve objects from a session object.

4.2

Given a scenario describe the APIs used to access the session object, explain when the session object was created, and describe the mechanisms used to destroy the session object, and when it was destroyed.

4.3

Using session listeners, write code to respond to an event when an object is added to a session, and write code to respond to an event when a session object migrates from one VM to another.

4.4

Given a scenario, describe which session management mechanism the Web container could employ, how cookies might be used to manage sessions, how URL rewriting might be used to manage sessions, and write servlet code to perform URL rewriting.

Coverage Notes:

All four of the exam objectives on session management are covered completely in this chapter (although some of these topics were touched on in the previous chapter). This chapter is your one chance to learn and memorize these topics, so take your time.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset