Tag lifecycle in JSP page

The following is the flow of methods that are called on a tag when it's encountered in a page:

  1. Two methods, setParent() and setPageContext(), are called on the TagHandler class. These methods are handled automatically by BodyTagSupport and TagSupport so you don't need to implement them explicitly if your tag extends either one of them.
  2. Any set methods for attributes on this tag are called.
  3. doStartTag() is called. If you haven't implemented this method, the flow continues. Otherwise you must return one of the following:
    • SKIP_BODY: Instructs the engine to ignore the body for this tag if one exists
    • EVAL_BODY_TAG: Instructs the engine to evaluate the body and call the Tag's doInitBody() method (relevant only for tags that implement the BodyTag interface; tags that extend from BodyTagSupport implement this interface)
    • EVAL_BODY_INCLUDE: Instructs the engine to evaluate and include anything in the tag body; engine proceeds to step 7 (relevant only for tags that implement the BodyTag interface; tags that extend from BodyTagSupport implement this interface)
  4. setBodyContent() is called on the tag. This allows classes that extend BodyTagSupport to evaluate, manipulate and modify the body of the tag.
  5. doInitBody is called. Any initialization necessary before doAfterBody is called can be done here (setting up Connections, setting variables in the pageContext, etc.).
  6. doAfterBody is called. A return value of SKIP_BODY here will result in doEndTag() being called. Returning EVAL_BODY_TAG will produce another call to doAfterBody.
  7. doEndTag() is called. A return value of EVAL_PAGE here will result in the rest of the JSP page being evaluated by the engine. Returning SKIP_PAGE will tell the engine to ignore the rest of the page.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值