package com.acme.tag; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; /** * A simple Tag that displays a Hello World message. * @author Magnus Rydin */ public class HelloWorldTag implements Tag { private PageContext pageContext; private Tag parent; /** * Constructor */ public HelloWorldTag() { super(); } /** * Method called at start of Tag * @return either a EVAL_BODY_INCLUDE or a SKIP_BODY */ public int doStartTag() throws javax.servlet.jsp.JspTagException { return SKIP_BODY; } /** * Method Called at end of Tag * @return either EVAL_PAGE or SKIP_PAGE */ public int doEndTag() throws javax.servlet.jsp.JspTagException { try { pageContext.getOut().write("Hello World!"); } catch(java.io.IOException e) { throw new JspTagException("IO Error: " + e.getMessage()); } return EVAL_PAGE; } /** * Method called to releases all resources */ public void release() {} /** Method used by the JSP container to set the current PageContext * @param pageContext, the current PageContext */ public void setPageContext(final javax.servlet.jsp.PageContext pageContext) { this.pageContext=pageContext; } /** Method used by the JSP container to set the parent of the Tag * @param parent, the parent Tag */ public void setParent(final javax.servlet.jsp.tagext.Tag parent) { this.parent=parent; } /** Method for retrieving the parent * @return the parent */ public javax.servlet.jsp.tagext.Tag getParent() { return parent; } }