Session Based Shopping Cart

Article Index

1 1 1 1 1 1 1 1 1 1 Rating 3.61 (54 Votes)

This workshop is for you, if:

  • You want to get hands on feel of JSP and Servlets in real life scenarios
  • You are dying to write some code and see it work
  • You have heard enough about shopping carts and finally want to see what the heck, they are made of!

This workshop is not for you, if:

  • You do not have any idea about JSP, Servlets or core Java
  • You are looking for a production quality or ready to use shopping cart wink



  • Knowledge of Java fundamentals and collection framework
  • JSP and servlet knowledge, especially, about session handling and JSTL
  • Setup of environment: Tomcat and IDE. Check article



  • Create simple catalog page with hard coded list of models with an ‘Add to Cart’ button.
  • The catalog model list page should contain a list of models with model number, description and price.
  • On clicking the ‘Add to Cart’ button, the model should get added to the shopping cart.
  • The cart should display all the models added to it. For each line item, it should display model number, description and unit price of item and total price. It should also display the total price for the whole order.
  • For each item in the cart, there should be a delete button next to it for removing the item from cart.
  • For each item in the cart, there should be a text input to enter a quantity value with update button to update the quantity of item in the cart.
  • The cart should have a link back to catalog model list page.

 Shopping Cart overview:

Shopping cart is the heart of any e-commerce application. It is something highly talked about. But, what do you mean by a session based shopping cart? Well, shopping carts can be mainly session based or database based. As the name indicates, session based carts are completely maintained in the user’s session. Only after the checkout is completed, the information is persisted in the database. On the other hand, a database based shopping cart is maintained in the database. Every time cart items are added or updated, it gets persisted in the database. Both of them have their own advantages and disadvantages. For each add or update in database based cart, there will be a hit in the database. On the other hand, it gives us the advantage of cart persistence. You can leave your shopping halfway and come back after sometime and resume the shopping session.

Joomla SEO by MijoSEF