KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > token > TokenTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.token;
14
15 import java.io.IOException JavaDoc;
16
17 import javax.servlet.jsp.JspException JavaDoc;
18 import javax.servlet.jsp.JspWriter JavaDoc;
19 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
20
21 /**
22  * @author av
23  */

24 public class TokenTag extends TagSupport JavaDoc {
25
26   boolean clear;
27
28   public int doStartTag() throws JspException JavaDoc {
29     try {
30       RequestToken s = RequestToken.instance(pageContext.getSession());
31       JspWriter JavaDoc out = pageContext.getOut();
32       if (clear)
33         s.setToken(null);
34       else {
35         out.println(
36           "<input type=\"hidden\" name=\""
37             + s.getHttpParameterName()
38             + "\" value=\""
39             + s.getToken()
40             + "\" />");
41       }
42     } catch (IOException JavaDoc e) {
43       throw new JspException JavaDoc(e);
44     }
45     return super.doStartTag();
46   }
47
48   public void setClear(boolean b) {
49     clear = b;
50   }
51
52 }
53
Popular Tags