A 
doAfterBody()
 invocation returns an indication of whether further reevaluations of the 
body text should be done by the JSP page; as in the case of 
doStartTag()
, if 
EVAL_BODY_TAG is returned, the body is reevaluated, while a return value of 
SKIP_BODY will stop reevaluations.  Note that, since server side objects (accessible via 
pageContext, or through nested handlers) may have changed, each evaluation may produce 
very different content to be added to the 
BodyContent
 object.
Cooperating Actions
Often the best way to describe some functionality is through several cooperating actions.  For 
example, an action may be used to describe information that leads to the creation of some 
server side object, while another action may use that object elsewhere in the page.  One way 
for these actions to cooperate is explicitly, via using scripting variables: one action creates an 
object and gives it a name, the other refers to it through this name.  Scripting variables are 
discussed briefly below.
Two actions can also cooperate implicitly using different conventions.  For example, perhaps 
the last action applies, or perhaps there is only one action of a given type per JSP page.  A 
more flexible and very convenient mechanism for action cooperation is using the nesting 
structure to describe scoping.  Each tag handler is told of its parent tag handler (if any) using 
a setter method; the 
findAncestorWithClass
 static method in 
TagSupport
 can then 
be used to locate a tag handler with some given properties.
Actions Defining Scripting Variables
A custom action may create some server side objects and make them available to the 
scripting elements by creating or updating some scripting variables.  The specific variables 
thus effected may vary with the action instance.  The details of this are described through 
subclasses of 
javax.servlet.jsp.tagext.TagExtraInfo
 which are used at JSP 
page translation time.  The 
TagExtraInfo
 class provides methods that will indicate what 
are the names and types of the scripting variables that will be assigned objects (at request 
time) by the action.  These methods are passed a TagData instance that describes the 
attributes of a given action.  The responsibility of the tag library author is to faithfully 
indicate this information in the TagExtraInfo class; the corresponding Tag object must add 
the objects to the pageContext object.  It is the responsibility of the JSP page translator to 
automatically supply all the required code to do the  synchronization  between the 
pageObject values and the scripting variables.
5.1.3
Examples
This section outlines some simple, and common, uses of the tag extension mechanism. See 
Appendix A for more details on these examples and for additional examples of custom 
actions.
89
JavaServer Pages 1.1 Specification  
November 30, 1999




JSP Web Hosting JavaServer Pages Specifications JSP Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.