KickJava   Java API By Example, From Geeks To Geeks.

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


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  * JSP Tag <b>session</b>, used to access HttpSession information using
26  * the standard JSP &lt;jsp:getProperty&gt; tag.
27  * <p>
28  * The script variable of name <b>id</b> is available for use during
29  * processing of the remainder of the JSP page.
30  * <p>
31  * JSP Tag Lib Descriptor
32  * <p><pre>
33  * &lt;name&gt;session&lt;/name&gt;
34  * &lt;tagclass&gt;org.apache.taglibs.session.SessionTag&lt;/tagclass&gt;
35  * &lt;teiclass&gt;org.apache.taglibs.session.SessionTEI&lt;/teiclass&gt;
36  * &lt;bodycontent&gt;empty&lt;/bodycontent&gt;
37  * &lt;info&gt;Used to access general information about session.&lt;/info&gt;
38  * &lt;attribute&gt;
39  * &lt;name&gt;id&lt;/name&gt;
40  * &lt;required&gt;true&lt;/required&gt;
41  * &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
42  * &lt;/attribute&gt;
43  * </pre>
44  *
45  * @see SessionData
46  * @see SessionTEI
47  *
48  * @author Glenn Nielsen
49  */

50
51 public class SessionTag extends TagSupport
52 {
53     /**
54      * Method called at start of tag, gets HttpSession and creates a
55      * script variable of name id.
56      *
57      * @return SKIP_BODY
58      */

59     public final int doStartTag() throws JspException
60     {
61     pageContext.setAttribute(id,
62         new SessionData(pageContext.getSession()),
63         PageContext.PAGE_SCOPE);
64     return SKIP_BODY;
65     }
66 }
67
Popular Tags