import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class ShoppingCartViewerHidden extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("Current Shopping Cart Items"); out.println(""); // Cart items are passed in as the item parameter. String[] items = req.getParameterValues("item"); // Print the current cart items. out.println("You currently have the following items in your cart:
"); if (items == null) { out.println("None"); } else { out.println(""); } // Ask if the user wants to add more items or check out. // Include the current items as hidden fields so they'll be passed on. out.println("
"); // submit to self if (items != null) { for (int i = 0; i < items.length; i++) { out.println(""); } } out.println("Would you like to
"); out.println(""); out.println(""); out.println("
"); out.println(""); } }