JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»
6.9.1    Review of tag life cycle


Looking back at the tag’s life cycle as explained in chapter
4, we can divide the tag life cycle into five stages:


■    A tag is created. It should then have some initial state that allows it to be used by the JSP environment as needed.


■    The JSP environment initializes the tag. At this time, the JSP environment sets various properties into the tag, starting with the pageContext and parent properties, and ending with other properties as specified by the tag attributes and the TLD.


■    The JSP environment puts the tag into service by calling dostartTag().


The tag is now starting to collect state needed for the current execution.


■    The JSP environment informs the tag that the current service is done by calling doEndTag(). The tag should now free all the resources accumulated for the ended service phase. At the end of doEndTag(), the tag should be in a state that allows it to be reused again at the same JSP page.


■    The JSP environment puts the tag into reuse by calling its reiease() method. The tag should now recycle itself, returning to the same state as when it was created.


All this life cycle discussion makes it clear that there are two cleanup points:


1    doEndTag() —The tag must free all the state allocated for its current service period.


2 reiease()—The tag must recycle itself. This usually entails clearing the tag’s properties (for example pageContext and parent), since all other state was probably part of the service phase.

Скачать в pdf «JSP Tag Libraries»