/* * TPCW_buy_request_servlet.java - Servlet Class implements the buy request * web interaction. * ************************************************************************ * * This is part of the the Java TPC-W distribution, * written by Harold Cain, Tim Heil, Milo Martin, Eric Weglarz, and Todd * Bezenek. University of Wisconsin - Madison, Computer Sciences * Dept. and Dept. of Electrical and Computer Engineering, as a part of * Prof. Mikko Lipasti's Fall 1999 ECE 902 course. * * Copyright (C) 1999, 2000 by Harold Cain, Timothy Heil, Milo Martin, * Eric Weglarz, Todd Bezenek. * * This source code is distributed "as is" in the hope that it will be * useful. It comes with no warranty, and no author or distributor * accepts any responsibility for the consequences of its use. * * Everyone is granted permission to copy, modify and redistribute * this code under the following conditions: * * This code is distributed for non-commercial use only. * Please contact the maintainer for restrictions applying to * commercial use of these tools. * * Permission is granted to anyone to make or distribute copies * of this code, either as received or modified, in any * medium, provided that all copyright notices, permission and * nonwarranty notices are preserved, and that the distributor * grants the recipient permission for further redistribution as * permitted by this document. * * Permission is granted to distribute this code in compiled * or executable form under the same conditions that apply for * source code, provided that either: * * A. it is accompanied by the corresponding machine-readable * source code, * B. it is accompanied by a written offer, with no time limit, * to give anyone a machine-readable copy of the corresponding * source code in return for reimbursement of the cost of * distribution. This written offer must permit verbatim * duplication by anyone, or * C. it is distributed by someone who received only the * executable form, and is accompanied by a copy of the * written offer of source code that they received concurrently. * * In other words, you are welcome to use, share and improve this codes. * You are forbidden to forbid anyone else to use, share and improve what * you give them. * ************************************************************************ * * Changed 2003 by Jan Kiefer. * ************************************************************************/ import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.Date; import tpcw_dto.*; public class TPCW_buy_request_servlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { PrintWriter out = res.getWriter(); String url; // Set the content type of this servlet's result. res.setContentType("text/html"); HttpSession session = req.getSession(false); String C_ID = req.getParameter("C_ID"); String SHOPPING_ID = req.getParameter("SHOPPING_ID"); String RETURNING_FLAG = req.getParameter("RETURNING_FLAG"); Customer cust = null; out.print("\n"); out.print("TPC-W Buy Request\n"); out.print("\n"); out.print("

TPC Web Commerce Benchmark " + "(TPC-W)

\n"); out.print("

Buy Request Page

\n"); if(RETURNING_FLAG==null){ out.print("ERROR: RETURNING_FLAG not set!"); return; } if(RETURNING_FLAG.equals("Y")){ String UNAME = req.getParameter("UNAME"); String PASSWD = req.getParameter("PASSWD"); if(UNAME.length() == 0 || PASSWD.length() == 0){ out.print("Error: Invalid Input"); return; } cust = TPCW_Database.getCustomer(UNAME); TPCW_Database.refreshSession(cust.c_id); if(!PASSWD.equals(cust.c_passwd)){ out.print("Error: Incorrect Password"); return; } } else if(RETURNING_FLAG.equals("N")){ cust = new Customer(); cust.c_fname = req.getParameter("FNAME"); cust.c_lname = req.getParameter("LNAME"); cust.addr_street1 = req.getParameter("STREET1"); cust.addr_street2 = req.getParameter("STREET2"); cust.addr_city = req.getParameter("CITY"); cust.addr_state = req.getParameter("STATE"); cust.addr_zip = req.getParameter("ZIP"); cust.co_name = req.getParameter("COUNTRY"); cust.c_phone = req.getParameter("PHONE"); cust.c_email = req.getParameter("EMAIL"); cust.c_birthdate = new Date(req.getParameter("BIRTHDATE")); cust.c_data = req.getParameter("DATA"); cust = TPCW_Database.createNewCustomer(cust); } else out.print("ERROR: RETURNING_FLAG not set to Y or N!\n"); if(SHOPPING_ID == null){ out.print("ERROR: Shopping Cart ID not set!"); return; } //Update the shopping cart cost and get the current contents Cart mycart = TPCW_Database.getCart(Integer.parseInt(SHOPPING_ID), cust.c_discount); //Print out the web page out.print("
\n"); out.print("\n"); out.print("\n"); out.print(""); // //The Shipping Info Form // out.print("
\n"); out.print("

Billing Information:

\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); if(RETURNING_FLAG.equals("N")){ out.print("\n"); out.print("\n"); } out.print("
Firstname:" + cust.c_fname+"
Lastname: " + cust.c_lname +"
Addr_street_1:" + cust.addr_street1 + "
Addr_street_2:" + cust.addr_street2 + "
City:" + cust.addr_city + "
State:" + cust.addr_state + "
Zip:" + cust.addr_zip + "
Country:" + cust.co_name + "
Email:" + cust.c_email + "
Phone:" + cust.c_phone+ "
USERNAME:" + cust.c_uname + "
C_ID:" + cust.c_id + "
\n"); out.print("

Shipping Information:

\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); // //Order Information Section // out.print("
Addr_street_1:
Addr_street_ 2:
City:
State:
Zip:
Country:
\n"); out.print("

Order Information:

\n"); out.print("\n"); out.print("\n"); //Insert Shopping Cart Contents Here! // int i; for(i = 0; i < mycart.lines.size(); i++){ CartLine thisline = (CartLine) mycart.lines.elementAt(i); out.print("\n"); out.print(""); } out.print("
QtyProduct
" + thisline.scl_qty + "Title:"+thisline.scl_title + " - Backing: " + thisline.scl_backing); out.print("
SRP. $" + thisline.scl_srp); out.print("\n"); out.print("Your Price:" + thisline.scl_cost+ "\n"); out.print("
\n"); out.print("


\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("
Subtotal with discount (" + cust.c_discount + "%):$" + mycart.SC_SUB_TOTAL +"
Tax$" + mycart.SC_TAX +"
Shipping & Handling$" + mycart.SC_SHIP_COST+"
Total$" + mycart.SC_TOTAL +"
\n"); // //Credit Card Stuff // out.print("


\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("\n"); out.print("
Credit Card TypeVisa\n"); out.print("MasterCard\n"); out.print("Discover\n"); out.print("American Express\n"); out.print("Diners
Name on Credit Card
Credit Card Number
Credit Card Expiration Date
Shipping MethodAIR"); out.print("UPS\n"); out.print("FEDEX\n"); out.print("SHIP\n"); out.print("COURIER\n"); out.print("MAIL\n"); out.print("

\n"); // out.print("\n"); if(SHOPPING_ID != null) out.print("\n"); out.print("\n"); out.print("\n"); url = "TPCW_shopping_cart_interaction?ADD_FLAG=N&C_ID=" + cust.c_id; if(SHOPPING_ID != null) url = url + "&SHOPPING_ID=" + SHOPPING_ID; out.print("\n"); url = "TPCW_order_inquiry_servlet?C_ID=" + cust.c_id; if(SHOPPING_ID != null) url = url + "&SHOPPING_ID=" + SHOPPING_ID; out.print("\n"); out.print("

"); out.close(); return; } }