This is the most common way to implement session tracking. By rewriting URLs. It also does not allow the use of static pages. All HTML pages which are sent within a session have to be created dynamically. Our next Servlet manages a virtual shopping cart.
Users can add various items to their shopping cart via HTML forms.
The shopping cart contents are stored on the server and each user gets his own shopping cart which is selected automatically whenever he makes a request to the Servlet. ShoppingCartServlet there are only two kinds of items, named FOO and BAR . By pressing a button in an HTML form a single FOO or BAR item can be put into the shopping cart. There's another button to see the current contents of the shopping cart and a button to order the selected items, thus clearing the shopping cart. The doPost method processes the form data which is sent by a client in response to the form created by doGet .