javax.servlet.jsp.tagext
Class BodyTagSupport

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
All Implemented Interfaces:
java.io.Serializable, BodyTag, IterationTag, JspTag, Tag
Direct Known Subclasses:
CoreImportTag, CoreOutTag, CoreParamTag, CoreParamTag, CoreSetTag, CoreSetTag, FmtParamTag, FmtParamTag, FmtParseDateTag, FmtParseNumberTag, FormatDateTag, FormatDateTag, FormatNumberTag, FormatNumberTag, ImportTag, MessageTag, MessageTag, OutTag, ParseDateTag, ParseNumberTag, SqlParamTag, SqlParamTag, SqlQueryTag, SqlQueryTag, SqlUpdateTag, SqlUpdateTag, XmlParamTag, XmlParamTag, XmlParseTag, XmlParseTag, XmlTransformTag, XmlTransformTag

public class BodyTagSupport
extends TagSupport
implements BodyTag

Convenience class defining default behavior for a BodyTag. Most implementations will extend BodyTagSupport instead of implementing BodyTag directly.

The default behavior executes the body once, ignoring the contents.

See Also:
Serialized Form

Field Summary
protected  BodyContent bodyContent
           
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
BodyTagSupport()
          Implementing tags must implement a zero-arg constructor.
 
Method Summary
 int doAfterBody()
          Action after the body completes, returning EVAL_BODY_TAG to loop and SKIP_BODY to stop looping.
 void doInitBody()
          The default init action is to do nothing.
 int doStartTag()
          The default start action is EVAL_BODY_TAG, i.e.
 BodyContent getBodyContent()
          Returns the tag's body content.
 JspWriter getPreviousOut()
          Returns the enclosing writer.
 void release()
          Release the tag.
 void setBodyContent(BodyContent bodyContent)
          Called by the JSP engine just before calling doInitBody().
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
doEndTag, getParent, setPageContext, setParent
 

Field Detail

bodyContent

protected BodyContent bodyContent
Constructor Detail

BodyTagSupport

public BodyTagSupport()
Implementing tags must implement a zero-arg constructor.

Method Detail

setBodyContent

public void setBodyContent(BodyContent bodyContent)
Called by the JSP engine just before calling doInitBody(). Empty tags never have setBodyContent called on them. Because the JSP engine reuses BodyContents, a tag cannot use the body content after doAfterBody completes.

Specified by:
setBodyContent in interface BodyTag
Parameters:
bodyContent - a bodyContent generated by the JSP engine.

getBodyContent

public BodyContent getBodyContent()
Returns the tag's body content. The body content is in scope for the BodyTag methods doInitBody and doAfterBody, but not for the tag methods doStartTag and doEndTag.


getPreviousOut

public JspWriter getPreviousOut()
Returns the enclosing writer. For BodyTags with no body, this is equivalent to pageContext.getOut().


doStartTag

public int doStartTag()
               throws JspException
The default start action is EVAL_BODY_TAG, i.e. evaluate the body.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class TagSupport
Returns:
SKIP_BODY to ignore the body and EVAL_BODY_INCLUDE to evaluate the body.
Throws:
JspException

doInitBody

public void doInitBody()
                throws JspException
The default init action is to do nothing.

Specified by:
doInitBody in interface BodyTag
Throws:
JspException

doAfterBody

public int doAfterBody()
                throws JspException
Action after the body completes, returning EVAL_BODY_TAG to loop and SKIP_BODY to stop looping.

The default action is to only execute the body once.

Specified by:
doAfterBody in interface BodyTag
Specified by:
doAfterBody in interface IterationTag
Overrides:
doAfterBody in class TagSupport
Returns:
EVAL_BODY_AGAIN to repeat the body or SKIP_BODY to stop.
Throws:
JspException

release

public void release()
Release the tag.

Specified by:
release in interface Tag
Overrides:
release in class TagSupport