KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > web > SimpleTag


1
2 package test.web;
3
4 import javax.servlet.http.HttpServletRequest JavaDoc;
5 import javax.servlet.jsp.JspTagException JavaDoc;
6 import javax.servlet.jsp.JspWriter JavaDoc;
7 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
8 import java.io.IOException JavaDoc;
9
10 /**
11  * Simple JSP tag.
12  *
13  * @jsp.tag name="simple"
14  * display-name="SimpleTag"
15  * body-content="empty"
16  * description="Simple JSP tag."
17  *
18  * @author <a HREF="mailto:youremail@yourdomain.com">youremail@yourdomain.com</a>
19  */

20 public class SimpleTag extends TagSupport JavaDoc {
21     private String JavaDoc action = null;
22
23     /**
24      * Sets the action attribute. This is included in the tld file.
25      *
26      * @jsp.attribute
27      * description="The action attribute"
28      * required="true"
29      * rtexprvalue="true"
30      */

31     public String JavaDoc getAction() {
32         return this.action;
33     }
34
35     /**
36      */

37     public void setAction(String JavaDoc action) {
38         this.action = action;
39     }
40
41     /** Process the start tag for this instance. */
42     public int doStartTag() throws JspTagException JavaDoc {
43         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) pageContext.getRequest();
44
45         try {
46             JspWriter JavaDoc out = pageContext.getOut();
47
48             out.print("Simple tag started.");
49         }
50         catch (IOException JavaDoc ioe) {
51             ioe.printStackTrace();
52         }
53
54         return EVAL_BODY_INCLUDE;
55     }
56
57     /** Process the end tag. This method will be called on all Tag objects. */
58     public int doEndTag() {
59         try {
60             JspWriter JavaDoc out = pageContext.getOut();
61
62             out.print("Simple tag ended.");
63         }
64         catch (IOException JavaDoc ioe) {
65             ioe.printStackTrace();
66         }
67
68         return EVAL_PAGE;
69     }
70 }
Popular Tags