Session Tracking
Why?
When clients at an on line store add an item to their 
shopping cart, how does the server know what's already 
in the cart?
When clients decide to proceed to checkout, how can the 
server determine which previously created shopping cart 
is theirs?
How?
Cookies
URL rewriting
Hidden form fields
Higher level API needed
87
Servlets
www.corewebprogramming.com
The Session Tracking API
Session objects live on the server
Automatically associated with client via 
cookies or URL rewriting
Use 
request.getSession(true)
to get either existing or new 
session
Behind the scenes, the system looks at cookie or 
URL extra info and sees if it matches the key to some 
previously stored session object. If so, it returns that 
object. If not, it creates a new one, assigns a cookie 
or URL info as its key, and returns that new session 
object.
Hashtable like mechanism lets you store 
arbitrary objects inside session
setAttribute
stores values
getAttribute
retrieves values
88
Servlets
www.corewebprogramming.com
44




  

Home

About Services Network Support FAQ Order Contact
 

Servlet Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved