javax.servlet.jsp.tagext
Interface SimpleTag

All Superinterfaces:
JspTag
All Known Implementing Classes:
SimpleTagSupport

public interface SimpleTag
extends JspTag

Interface for defining Simple Tag Handlers.

Simple Tag Handlers differ from Classic Tag Handlers in that instead of supporting doStartTag() and doEndTag(), the SimpleTag interface provides a simple doTag() method, which is called once and only once for any given tag invocation. All tag logic, iteration, body evaluations, etc. are to be performed in this single method. Thus, simple tag handlers have the equivalent power of IterationTag, but with a much simpler lifecycle and interface.

To support body content, the setJspBody() method is provided. The container invokes the setJspBody() method with a JspFragment object encapsulating the body of the tag. The tag handler implementation can call invoke() on that fragment to evaluate the body as many times as it needs.

A SimpleTag handler must have a public no-args constructor. Most SimpleTag handlers should extend SimpleTagSupport.

Lifecycle

The following is a non-normative, brief overview of the SimpleTag lifecycle. Refer to the JSP Specification for details.

  1. A new tag handler instance is created each time by the container by calling the provided zero-args constructor.
  2. The setJspContext() and setParent() are called by the container.
  3. The setters for each attribute defined for this tag are called by the container, in the order in which they appear in the JSP page or Tag File.
  4. The setJspBody() method is called by the container to set the body of this tag, as a JspFragment.
  5. The doTag() method is called by the container. All tag logic, iteration, body evaluations, etc. occur in this method.
  6. The doTag() method returns and all variables are synchronized.

Since:
JSP2.0
See Also:
SimpleTagSupport

Method Summary
 void doTag()
          Called by the container to invoke this tag.
 JspTag getParent()
          Returns the parent of this tag, for collaboration purposes.
 void setJspBody(JspFragment jspBody)
          Provides the body of this tag as a JspFragment object, able to be invoked zero or more times by the tag handler.
 void setJspContext(JspContext pc)
          Stores the provided JSP context in the protected jspContext field.
 void setParent(JspTag parent)
          Sets the parent of this tag, for collaboration purposes.
 

Method Detail

doTag

public void doTag()
           throws JspException,
                  java.io.IOException
Called by the container to invoke this tag. The implementation of this method is provided by the tag library developer, and handles all tag processing, body iteration, etc.

Throws:
JspException - If an error occurred while processing this tag.
SkipPageException - If the page that (either directly or indirectly) invoked this tag is to cease evaluation. A Simple Tag Handler generated from a tag file must throw this exception if an invoked Classic Tag Handler returned SKIP_PAGE or if an invoked Simple Tag Handler threw SkipPageException or if an invoked Jsp Fragment threw a SkipPageException.
java.io.IOException - If there was an error writing to the output stream.

setParent

public void setParent(JspTag parent)
Sets the parent of this tag, for collaboration purposes.

Parameters:
parent - the tag that encloses this tag

getParent

public JspTag getParent()
Returns the parent of this tag, for collaboration purposes.

Returns:
the parent of this tag

setJspContext

public void setJspContext(JspContext pc)
Stores the provided JSP context in the protected jspContext field.

Parameters:
pc - the page context for this invocation
See Also:
Tag.setPageContext(javax.servlet.jsp.PageContext)

setJspBody

public void setJspBody(JspFragment jspBody)
Provides the body of this tag as a JspFragment object, able to be invoked zero or more times by the tag handler.

This method is invoked by the JSP page implementation object prior to doTag().

Parameters:
jspBody - The fragment encapsulating the body of this tag, or null if this tag as a body content type of empty.


Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.