Completing the Order
With the beans in place to record orders and authorize credit cards, you can write the JSP to run the credit card and complete the order (see Listing 13.9).
Listing 13.9. authorizePurchase.jsp
<%@ include file="/jsp/cust/AutoLogin.jsp" %> <%@ page import="com.bfg.product.Product" %> <%@ page import="com.bfg.product.Order" %> <%@ page import="java.util.Iterator" %> <%@ page import="com.bfg.cart.CartItem" %> <jsp:useBean id="orderaddr" class="com.bfg.customer.Address" scope="session"/> <jsp:useBean id="ordercredit" class="com.bfg.customer.CreditCard" scope="session"/> <jsp:useBean id="cart" class="com.bfg.cart.Cart" scope="session"/> <jsp:useBean id="customer" class="com.bfg.customer.Customer" scope="session"/> <% if (!cart.authorizeCharge(ordercredit)) ... |
Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.