Java Reference
In-Depth Information
Fig. 8.8
Weight entry page for simple shopping cart application
When a selection has been made and 'Submit' clicked, the Weight servlet is exe-
cuted. Here is the code for the Weight servlet:
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
public class Weight extends HttpServlet
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException,ServletException
HttpSession cart = request.getSession();
String currentProduct =
//Current product ('Apples' or 'Pears') retrieved.
//Note the necessity for a typecast from Object
//into String.
Search WWH ::

Custom Search