1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package sessions;
17
18 import javax.servlet.http.*;
19 import java.util.Vector;
20 import java.util.Enumeration;
21
22 public class DummyCart {
23 Vector v = new Vector();
24 String submit = null;
25 String item = null;
26
27 private void addItem(String name) {
28 v.addElement(name);
29 }
30
31 private void removeItem(String name) {
32 v.removeElement(name);
33 }
34
35 public void setItem(String name) {
36 item = name;
37 }
38
39 public void setSubmit(String s) {
40 submit = s;
41 }
42
43 public String[] getItems() {
44 String[] s = new String[v.size()];
45 v.copyInto(s);
46 return s;
47 }
48
49 public void processRequest(HttpServletRequest request) {
50
51
52 if (submit == null)
53 addItem(item);
54
55 if (submit.equals("add"))
56 addItem(item);
57 else if (submit.equals("remove"))
58 removeItem(item);
59
60
61 reset();
62 }
63
64
65 private void reset() {
66 submit = null;
67 item = null;
68 }
69 }