package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; /** * This is a simple tag example to show how content is added to the * output stream when a tag is encountered in a JSP page. */ public class Hellotest extends TagSupport { private String name=null; /** * Getter/Setter for the attribute name as defined in the tld file * for this tag */ public void setName(String value){ name = value; } public String getName(){ return(name); } /** * doStartTag is called by the JSP container when the tag is encountered */ public int doStartTag() { try { JspWriter out = pageContext.getOut(); out.println(""); if (name != null) out.println(""); else out.println(""); } catch (Exception ex) { throw new Error("All is not well in the world."); } // Must return SKIP_BODY because we are not supporting a body for this // tag. return SKIP_BODY; } /** * doEndTag is called by the JSP container when the tag is closed */ public int doEndTag(){ try { JspWriter out = pageContext.getOut(); out.println("
Hello " + name + "
Hello World
"); } catch (Exception ex){ throw new Error("All is not well in the world."); } return EVAL_PAGE; } }