KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > session > SessionData


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.session;
18
19 import javax.servlet.*;
20 import javax.servlet.http.*;
21 import javax.servlet.jsp.*;
22 import javax.servlet.jsp.tagext.*;
23
24 /**
25  * Used to store the scripting variable data provided by the JSP Tag
26  * <b>session</b>, used to access HttpSession information using
27  * the standard JSP &lt;jsp:getProperty&gt; tag.
28  * <p>
29  * The script variable of name <b>id</b> is available for use during
30  * processing of the remainder of the JSP page.
31  * <p>
32  *
33  * @see SessionTag
34  *
35  * @author Glenn Nielsen
36  */

37
38 public class SessionData
39 {
40     private HttpSession sess;
41
42     SessionData(HttpSession session)
43     {
44     this.sess = session;
45     }
46
47     /**
48      * Returns the time when this session was created, measured in
49      * milliseconds since midnight January 1, 1970 GMT as a String.
50      * <p>
51      * &lt;jsp:getProperty name=<i>"id"</i> property="creationTime"/&gt;
52      *
53      * @return String - creation of session in milliseconds
54      */

55     public final String JavaDoc getCreationTime()
56     {
57     return "" + sess.getCreationTime();
58     }
59
60     /**
61      * Returns a string containing the unique identifier assigned to this
62      * session.
63      * <p>
64      * &lt;jsp:getProperty name=<i>"id"</i> property="sessionId"/&gt;
65      *
66      * @return String - session id
67      */

68     public final String JavaDoc getSessionId()
69     {
70     return sess.getId();
71     }
72
73     /**
74      * Returns the last time the client sent a request associated with
75      * this session, as the number of milliseconds since midnight
76      * January 1, 1970 GMT as a String.
77      * <p>
78      * &lt;jsp:getProperty name=<i>"id"</i> property="lastAccessedTime"/&gt;
79      *
80      * @return String - last time session was accessed in milliseconds
81      */

82     public final String JavaDoc getLastAccessedTime()
83     {
84     return "" + sess.getLastAccessedTime();
85     }
86
87     /**
88      * Returns the maximum time interval, in seconds, that the servlet
89      * container will keep this session open between client accesses.
90      * <p>
91      * &lt;jsp:getProperty name=<i>"id"</i> property="maxInactiveInterval"/&gt;
92      *
93      * @return String - the maximum inactive interval in seconds
94      */

95     public final String JavaDoc getMaxInactiveInterval()
96     {
97     return "" + sess.getMaxInactiveInterval();
98     }
99 }
100
Popular Tags