JSP tag loop TAG body

Source: Internet
Author: User

Reference: http://liuna718-163-com.iteye.com/blog/1318991

1. The iterationtag interface is a sub-interface of the tag interface, which has a doafterbody method. This method determines whether to repeatedly execute the TAG body content.

2. The Web Container executes the custom tag process as follows:
Call the setpagecontent () method during initialization. After the setparent method is called
2.1the Web Container first executes the start tag of the custom tag and calls the dostarttag method.
2.2 If the dostarttag method returns eval_body_include, the Web Container will call the doafterbody method of the label class after the content of the label body is executed;
If the dostarttag method returns skip_body, The doafterbody method will not be called, and the Web Container will directly call the doendtag method in the tag class.
2.3 If the doafterbody method is called and the method returns eval_body_agin, the Web Container will execute the content of the label body again;
If the doafterbody method returns the skip_body, the Web Container will call the doendtag method of the label class.
2.4 If the doendtag method returns eval_page, the Web Container executes the content following the tag;
If the doendtag method returns skip_page, the Web Container ignores the content after the custom tag.

3. Implement the bodytagsupport class of the bodytag Interface
Pay attention to the following points when writing code:
Because the setpagecontext method, setparent method, setter method of attributes, and dostarttag method are called before the setbodycontent method, you cannot use bodycontext objects in these methods, that is to say, the bodycontent object can be used only in the methods called after the setbodycontent method, such as the doinitbody, doafterbody, and doendbody methods.
If you want to modify the content of the TAG body, you can only process the content after the TAG body is executed. That is to say, you can only write the processing code in the doafterbody or doendtag method.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.