If the tag handler needs to manipulate the body, the tag handler must capture the body in a StringWriter. The invoke method directs all output to a supplied writer. Then the modified body is written to the JspWriter returned by the getOut method of the JspContext. Thus, a tag that converts its body to uppercase could be written as follows:
public class SimpleWriter extends SimpleTagSupport { public void doTag() throws JspException, IOException { StringWriter sw = new StringWriter(); jspBody.invoke(sw); jspContext(). getOut().println(sw.toString().toUpperCase()); } }