|
Home TOC Index |
|
Search
Feedback |
How Is a Tag Handler Invoked?
The
Taginterface defines the basic protocol between a tag handler and a JSP page's servlet. It defines the life cycle and the methods to be invoked when the start and end tags are encountered.The JSP page's servlet invokes the
setPageContext,setParent, and attribute setting methods before callingdoStartTag. The JSP page's servlet also guarantees thatreleasewill be invoked on the tag handler before the end of the page.Here is a typical tag handler method invocation sequence:
ATag t = new ATag(); t.setPageContext(...); t.setParent(...); t.setAttribute1(value1); t.setAttribute2(value2); t.doStartTag(); t.doEndTag(); t.release();The
BodyTaginterface extendsTagby defining additional methods that let a tag handler access its body. The interface provides three new methods:
setBodyContent: Creates body content and adds to the tag handler
doInitBody: Called before evaluation of the tag body
doAfterBody: Called after evaluation of the tag bodyA typical invocation sequence is as follows:
t.doStartTag(); out = pageContext.pushBody(); t.setBodyContent(out); // perform any initialization needed after body content is set t.doInitBody(); t.doAfterBody(); // whiledoAfterBodyreturnsEVAL_BODY_BUFFEREDwe // iterate body evaluation ... t.doAfterBody(); t.doEndTag(); t.pageContext.popBody(); t.release();
|
Home TOC Index |
|
Search
Feedback |