KickJava   Java API By Example, From Geeks To Geeks.

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


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

12
13 package org.ejtools.jmx.browser.web.taglib;
14
15
16
17 import javax.servlet.ServletContext JavaDoc;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20
21 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
22
23
24
25 import org.ejtools.jmx.browser.web.Constants;
26
27
28
29 /**
30
31  * Description of the Class
32
33  *
34
35  * @author letiemble
36
37  * @created 1 mars 2002
38
39  * @version $Revision: 1.6 $
40
41  * @todo Javadoc to complete
42
43  * @jsp:tag name="connect" body-content="empty"
44
45  */

46
47 public class ConnectTag extends TagSupport JavaDoc
48
49 {
50
51    /** The key of the application-scope bean we look for. */
52
53    private String JavaDoc name = Constants.TREE;
54
55    /** The page to which we should forward for the user to log on. */
56
57    private String JavaDoc page = "/connect.do";
58
59
60
61
62
63    /**
64
65     * Description of the Method
66
67     *
68
69     * @return Description of the Returned Value
70
71     * @exception JspException Description of the Exception
72
73     */

74
75    public int doEndTag()
76
77       throws JspException JavaDoc
78
79    {
80
81       boolean valid = false;
82
83
84
85       ServletContext JavaDoc context = pageContext.getServletContext();
86
87
88
89       if (context.getAttribute(name) != null)
90
91       {
92
93          valid = true;
94
95       }
96
97
98
99       // Forward control based on the results
100

101       if (valid)
102
103       {
104
105          return (EVAL_PAGE);
106
107       }
108
109       else
110
111       {
112
113          try
114
115          {
116
117             pageContext.forward(page);
118
119          }
120
121          catch (Exception JavaDoc e)
122
123          {
124
125             throw new JspException JavaDoc("Error during forwarding to " + page);
126
127          }
128
129          return (SKIP_PAGE);
130
131       }
132
133    }
134
135
136
137
138
139    /**
140
141     * Description of the Method
142
143     *
144
145     * @return Description of the Returned Value
146
147     * @exception JspException Description of the Exception
148
149     */

150
151    public int doStartTag()
152
153       throws JspException JavaDoc
154
155    {
156
157       return (SKIP_BODY);
158
159    }
160
161
162
163
164
165    /**
166
167     * Getter for the name attribute
168
169     *
170
171     * @return The value of name attribute
172
173     * @jsp:attribute name="name" required="false" rtexprvalue="true"
174
175     */

176
177    public String JavaDoc getName()
178
179    {
180
181       return (this.name);
182
183    }
184
185
186
187
188
189    /**
190
191     * Getter for the page attribute
192
193     *
194
195     * @return The value of page attribute
196
197     * @jsp:attribute name="page" required="false" rtexprvalue="true"
198
199     */

200
201    public String JavaDoc getPage()
202
203    {
204
205       return (this.page);
206
207    }
208
209
210
211
212
213    /** Description of the Method */
214
215    public void release()
216
217    {
218
219       super.release();
220
221       this.name = Constants.TREE;
222
223       this.page = "/connect.do";
224
225    }
226
227
228
229
230
231    /**
232
233     * Setter for the name attribute
234
235     *
236
237     * @param name The new name value
238
239     */

240
241    public void setName(String JavaDoc name)
242
243    {
244
245       this.name = name;
246
247    }
248
249
250
251
252
253    /**
254
255     * Setter for the page attribute
256
257     *
258
259     * @param page The new page value
260
261     */

262
263    public void setPage(String JavaDoc page)
264
265    {
266
267       this.page = page;
268
269    }
270
271 }
272
273
274
275
Popular Tags