The BodyContent argument to setBodyContent() is actually a type of java.io.Writer. (Yes, it’s OK to find that disturbing from an OO perspective.) But that means you can process the body by, say, chaining it to another IO stream or getting the raw bytes.
Q: What happens if I return EVAL_BODY_BUFFERED even though the invoking tag is empty?
A: The setBodyContent() and doInitBody() method will not be called if the tag invoking the handler is empty! And by empty, we mean that the tag was invoked using an empty tag <my:tag /> or with no content between the opening and closing tags <my:tag><my:tag>.
The Container knows there’s no body this time, and it just skips to the doEndTag() method, so this is usually not a problem.
Unless the TLD declares the tag to have an empty body! If the TLD says <body-content>empty</body-content>, you don’t have a choice, and you must NOT return EVAL_BODY_BUFFERED or EVAL_BODY_INCLUDE from doStartTag().
Q: What about attributes in a Classic tag? Are they handled the same way as with Simple tags?
A: Yes, on the sequence diagram for both Simple tag handlers and Classic tag handlers, there was a place where bean-style setter methods are called for each attribute. This happens before a Simple tag’s doTag() or a Classic tag’s doStartTag(). In other words, tag attributes work in exactly the same way for both Classic and Simple tags, including the way in which they’re declared in the TLD.
You don’t need to know all the ...