-
Notifications
You must be signed in to change notification settings - Fork 1
/
list.jsp
97 lines (77 loc) · 2.39 KB
/
list.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<%@ page import="java.util.*" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Shop</title>
<link rel="stylesheet" type="text/css" href="StyleSheet.css"/>
</head>
<body>
<div id="header">
<a href="Shop.xhtml">
<h1 class="head">Big O Doughnuts</h1>
</a>
</div>
<div id="main">
<div id="NavBar">
<ul>
<a href="Shop.xhtml">
<li>Main Shop</li>
</a>
<a href="New2017Collection.xhtml">
<li>New 2017 Collection</li>
</a>
<a href="WeddingCollection.xhtml">
<li>Wedding Collection</li>
</a>
<a href="Delivery.xhtml">
<li>Delivery</li>
</a>
<a href="AboutUs.xhtml">
<li>About Us</li>
</a>
</ul>
</div>
<h1 style="text-align:center;">Your Shopping Cart</h1>
<% if ( session.getAttribute("list1") == null && session.getAttribute("list2") == null && session.getAttribute("list3") == null){
session.setAttribute("list1", new Vector());
session.setAttribute("list2", new Vector());
session.setAttribute("list3", new Vector());
}
Vector list1 = (Vector)session.getAttribute("list1");
Vector list2 = (Vector)session.getAttribute("list2");
Vector list3 = (Vector)session.getAttribute("list3");
int item = Integer.parseInt(request.getParameter("item"));
String name = request.getParameter("donut");
int price = Integer.parseInt(request.getParameter("price"));
if ( name != null && name != "" )
list1.addElement(item);
list2.addElement(name);
list3.addElement(price * item);
String pick = request.getParameter("pick");
if ( pick != null && pick.equals("on") ) {
%>
<jsp:forward page="main.jsp" />
<%} else {%>
<h3>List of Items</h3>
<p>
<% if ( list1 != null ){
int totalprice = 0;
for (int i=0; i<list1.size(); i++){
out.println((int)list1.elementAt(i) + "x ");
out.print(" " + (String)list2.elementAt(i));
out.print(" - " + (int)list3.elementAt(i) + " Smackaroonies" + "<br/>" + "<br/>");
totalprice = totalprice + (int)list3.elementAt(i);
}
out.println("Total Price is " + totalprice + " Smackaroonies" + "<br/>" + "<br/>");
}
%>
<a href="ActualOrderPage.xhtml">
<input type=submit value="Check Out">
</a>
<%}%>
<a href="Shop.xhtml">
<input type=submit value="Continue Shopping" >
</a>
</div>
</body>
</html>