KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jndi > browser > web > taglib > ConnectTag


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.jndi.browser.web.taglib;
8
9 import javax.servlet.ServletContext JavaDoc;
10 import javax.servlet.jsp.JspException JavaDoc;
11 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
12
13 import org.ejtools.jndi.browser.web.Constants;
14
15 /**
16  * Description of the Class
17  *
18  * @author letiemble
19  * @created 1 mars 2002
20  * @version $Revision: 1.1 $
21  * @todo Javadoc to complete
22  * @jsp:tag name="connect"
23  * body-content="empty"
24  */

25 public class ConnectTag extends TagSupport JavaDoc
26 {
27    /** The key of the application-scope bean we look for. */
28    private String JavaDoc name = Constants.GLOBAL_TREE;
29    /** The page to which we should forward for the user to log on. */
30    private String JavaDoc page = "/refresh.do";
31
32
33    /**
34     * Description of the Method
35     *
36     * @return Description of the Returned Value
37     * @exception JspException Description of Exception
38     */

39    public int doEndTag()
40       throws JspException JavaDoc
41    {
42       boolean valid = false;
43
44       ServletContext JavaDoc context = pageContext.getServletContext();
45
46       if (context.getAttribute(name) != null)
47       {
48          valid = true;
49       }
50
51       // Forward control based on the results
52
if (valid)
53       {
54          return (EVAL_PAGE);
55       }
56       else
57       {
58          try
59          {
60             pageContext.forward(page);
61          }
62          catch (Exception JavaDoc e)
63          {
64             throw new JspException JavaDoc(e.toString());
65          }
66          return (SKIP_PAGE);
67       }
68    }
69
70
71    /**
72     * Description of the Method
73     *
74     * @return Description of the Returned Value
75     * @exception JspException Description of Exception
76     */

77    public int doStartTag()
78       throws JspException JavaDoc
79    {
80       return SKIP_BODY;
81    }
82
83
84    /**
85     * Getter for the name attribute
86     *
87     * @return The value of name attribute
88     * @jsp:attribute name="name" required="false" rtexprvalue="true"
89     */

90    public String JavaDoc getName()
91    {
92       return this.name;
93    }
94
95
96    /**
97     * Getter for the page attribute
98     *
99     * @return The value of page attribute
100     * @jsp:attribute name="page" required="false" rtexprvalue="true"
101     */

102    public String JavaDoc getPage()
103    {
104       return this.page;
105    }
106
107
108    /** Description of the Method */
109    public void release()
110    {
111       super.release();
112       this.name = Constants.GLOBAL_TREE;
113       this.page = "/refresh.do";
114    }
115
116
117    /**
118     * Setter for the name attribute
119     *
120     * @param name The new value for name attribute
121     */

122    public void setName(String JavaDoc name)
123    {
124       this.name = name;
125    }
126
127
128    /**
129     * Setter for the page attribute
130     *
131     * @param page The new value for page attribute
132     */

133    public void setPage(String JavaDoc page)
134    {
135       this.page = page;
136    }
137 }
138
Popular Tags