Thia is Question no 12 in chapter 10(HFSJ second edition)
Q. Which is true about the lifecycle of a Simple tag?
C.The setParent and SetJspContext bmethods are called immediately before the tag attributes are set.
D. The JspFragment of a tag's body is invoked by the container before the tag handler's doTag method is called. This value, a BodyContent object, is passed to the tag handler using the setJspBody method.
Answer is C.
But why D is incorrect, reason given is -the fragment is invoked by the doTag implementation but not before the doTag called.
But in lifecycle of simple tag on page 516 shows that setJspBody(JspFragment) is called before doTag method.
then why is reason is given like that?
posted 7 years ago
Hi Geeta. The JspFrament is an abstract class, the container provides the concrete class(JspFragmentImpl) by extending the JspFragment abstract class and encapsulates the body of the tag(not invokes) into it.
In the life cycle of simple tag, this object is set via. setJspBody(JspFragment).
The body will be invoked in doTag(), through getJspBody().invoke(java.io.Writer). Where the getJspBody() returns the JspFragmentImpl object, which is having the body of the tag encapsulated into it, and it will be invoked by invoke() method.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads