-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpSession.java
More file actions
123 lines (99 loc) · 4.12 KB
/
HttpSession.java
File metadata and controls
123 lines (99 loc) · 4.12 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package javaxt.http.servlet;
public class HttpSession {
private javax.servlet.http.HttpSession session;
private ServletContext context;
protected HttpSession(javax.servlet.http.HttpSession session, ServletContext context){
this.session = session;
this.context = context;
}
//**************************************************************************
//** getServletContext
//**************************************************************************
/** Returns the ServletContext.
*/
public ServletContext getServletContext(){
return context;
}
//**************************************************************************
//** getID
//**************************************************************************
/** Returns a string containing the unique identifier assigned to this
* session.
*/
public String getID(){
return session.getId();
}
//**************************************************************************
//** getCreationTime
//**************************************************************************
/** Returns the time when this session was created, measured in milliseconds
* since midnight January 1, 1970 GMT.
*/
public long getCreationTime(){
return session.getCreationTime();
}
//**************************************************************************
//** getLastAccessedTime
//**************************************************************************
/** Returns the time when this session was last accessed, measured in
* milliseconds since midnight January 1, 1970 GMT.
*/
public long getLastAccessedTime() {
return session.getLastAccessedTime();
}
//**************************************************************************
//** isNew
//**************************************************************************
/** Returns true if the client does not yet know about the session or if the
* server has not accessed the session.
*/
public boolean isNew(){
return session.isNew();
}
//**************************************************************************
//** getAttribute
//**************************************************************************
/** Returns the object bound with the specified name in this session, or
* null if no object is bound under the name.
*/
public Object getAttribute(String name){
return session.getAttribute(name);
}
//**************************************************************************
//** setAttribute
//**************************************************************************
/** Binds an object to this session, using the name specified.
*/
public void setAttribute(String name, Object value){
session.setAttribute(name, value);
}
//**************************************************************************
//** removeAttribute
//**************************************************************************
/** Removes the attribute with the given name from the servlet context. */
public void removeAttribute(String name){
session.removeAttribute(name);
}
//**************************************************************************
//** invalidate
//**************************************************************************
/** Invalidates this session then unbinds any objects bound to it.
*/
public void invalidate(){
session.invalidate();
}
//
// /** Generates a random sequence of alpha-numeric characters. */
// private static final String CreateID(int len){
// StringBuffer str = new StringBuffer(len);
// final String strValid = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// for (int i=1; i<=len; i++){
// int x = new java.util.Random().nextInt(strValid.length());
// str.append( strValid.substring(x,x+1) );
// }
// return str.toString();
// }
public String toString(){
return getID();
}
}