NOTE:
These slides have not been updated since 2003. They have been superseded by the book
Anders Møller and Michael Schwartzbach, February 2006 |
INTERACTIVE WEB SERVICES WITH JAVA |
A typical example:
... HttpSession session = request.getSession(true); ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingcart"); if (cart==null) { cart = new ShoppingCart(); session.setAttribute("shoppingcart", cart); } addItemToCart(cart); ... |
Under the hood: uses cookies or URL rewriting
(Since URL rewriting may be used, URLs to our own Servlets should always be passed through response.encodeURL(String))
Cookies can also be controlled manually...
This is a rather low-level approach - the session flow is not explicit in the code!
COPYRIGHT © 2002-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH |