Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
9.4 An On Line Store Using a Shopping Cart and Session Tracking
215
Figure 9 4
Result of the TechBooksPage servlet.
Handling the Orders
Listing 9.5 shows the servlet that handles the orders coming from the various
catalog pages shown in the previous subsection. It uses session tracking to
associate a shopping cart with each user. Since each user has a separate ses
sion, it is unlikely that multiple threads will be accessing the same shopping
cart simultaneously. However, if you were paranoid, you could conceive of a
few circumstances where concurrent access could occur, such as when a sin
gle user has multiple browser windows open and sends updates from more
than one very close together in time. So, just to be safe, the code synchro
nizes access based upon the session object. This prevents other threads that
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved