-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCookie.java
More file actions
99 lines (80 loc) · 2.49 KB
/
Cookie.java
File metadata and controls
99 lines (80 loc) · 2.49 KB
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
98
99
package javaxt.http.servlet;
//******************************************************************************
//** Cookie Class
//******************************************************************************
/**
* Creates a cookie, a small amount of information sent by a servlet to a
* Web browser, saved by the browser, and later sent back to the server. A
* cookie's value can uniquely identify a client, so cookies are commonly
* used for session management.
*
******************************************************************************/
public class Cookie {
javax.servlet.http.Cookie cookie;
public Cookie(String name, String value) {
this(new javax.servlet.http.Cookie(name, value));
}
public Cookie(javax.servlet.http.Cookie cookie){
this.cookie = cookie;
}
public void setPath(String path){
cookie.setPath(path);
}
public String getPath(){
return cookie.getPath();
}
public String getName(){
return cookie.getName();
}
public String getValue(){
return cookie.getValue();
}
public void setMaxAge(int deltaSeconds) {
cookie.setMaxAge(deltaSeconds);
}
// private void setExpires(java.util.Date expires) {
// cookie.s
// }
public void setSecure(boolean secure) {
cookie.setSecure(secure);
}
public void setComment(String comment) {
cookie.setComment(comment);
}
public void setVersion(int newVersion) {
cookie.setVersion(newVersion);
}
public String toString(){
String name = getName();
String value = getValue();
String path = getPath();
StringBuffer str;
if (value==null){
str = new StringBuffer(name.length() + 1);
str.append(name);
str.append(";");
}
else{
str = new StringBuffer(name.length() + value.length() + 2);
str.append(name);
str.append("=");
str.append(value);
str.append(";");
if (path!=null){
str.append(" Path=");
str.append(path);
}
}
//JSESSIONID=1f3de3ba66697674ff4a07bc561e; Path=/JavaXT
return str.toString();
}
public int hashCode(){
return cookie.hashCode();
}
public boolean equals(Object obj){
return cookie.equals(obj);
}
public javax.servlet.http.Cookie getCookie(){
return cookie;
}
}