Class 2 |
Intermediate Java 30-IT-397 |
|
Altering the Tag Body
-
In the last example, we basically left the body unaltered, but we don't
have to.
-
Instead of extending TagSupport, we must now extend BodyTagSupport,
which gives us new methods:
-
doAfterBody() allows you to change the tag body. Normally,
return SKIP_BODY to let it know you are finished procesing the body.
-
getBodyContent() gives us a BodyContent method that has information
about the tag body.
-
We'll also use some methods from the BodyContent class, given
to us from getBodyContent().
-
getEnclosingWriter() gives us the JspWriter that doStartTag and
doEndTag use. This is the stream to which we write the new body.
-
getEnclosingReader() returns a Reader that can give us the body
of the tag.
-
getString() returns a String of the entire tag body.
A Parsing Example

Created by: Brandan Jones
December 17, 2001