The Workshop is designed to help you review what you have learned, and help you to further increase your understanding of the material covered in this hour.
Why did we use a servlet instead of a JSP to add or remove items from the shopping cart?
In this example, the information about items was embedded in the URL used to add them to the shopping cart. How can you simplify the URL?
If you attempted to run the cookie example given in this hour, why didn't it work? (Hint: The code is okay.)
By nature, JSPs are oriented to presentation. After all, the majority of their content is markup. On the other hand, servlets are made up of code. Many designers choose to try and place most of the view in JSPs and to use servlets to implement functions involving the model. Adding or removing items from the shopping cart is a function that affects the model.
You can give the item an identifier that can be used to lookup information that is needed in other stages of the order. As mentioned in the text, the full description of the item can be stored in the application or session, or in a database.
Browsers will only accept cookies for the domain of the resource they requested. This prevents a server in the imacrook.com domain from changing a cookie that belongs to your online banking application. To get the example to work for you, change the cookie's domain.
Modify the shopping cart example to accept an order quantity from the user. Start with ShowProductCatalog2.jsp and use a form.
Change ShoppingCart.java so that it's notified when a session is terminated.
Modify the shopping cart example to use a cookie to store items that are in the shopping cart. Retrieve the cookie when the user first visits the application and repopulate the cart.