{"id":1716,"date":"2011-03-17T17:27:19","date_gmt":"2011-03-17T11:57:19","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=1716"},"modified":"2011-03-17T17:27:19","modified_gmt":"2011-03-17T11:57:19","slug":"life-cycle-of-jsp-bodytag-interface","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/life-cycle-of-jsp-bodytag-interface\/","title":{"rendered":"Life cycle of JSP BodyTag interface"},"content":{"rendered":"<p><a title=\"Life cycle of Tag interface\" href=\"https:\/\/jitendrazaa.com\/blog\/java\/life-cycle-of-jsp-tag-interface\/\">Previous article was about the life cycle of &#8220;Tag&#8221; interface<\/a>, in this article i am going to explain the life cycle of &#8220;BodyTag&#8221; interface.<\/p>\n<p>The <strong>BodyTag<\/strong> interface extends <strong>IterationTag <\/strong>by defining additional methods that let a tag handler <strong>manipulate the content of evaluating its body<\/strong>.<\/p>\n<figure id=\"attachment_1717\" aria-describedby=\"caption-attachment-1717\" style=\"width: 439px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Life-cycle-of-IterationTag-and-BodyTag-interface-in-JSP.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1717 \" title=\"Life cycle of IterationTag and BodyTag interface in JSP\" src=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Life-cycle-of-IterationTag-and-BodyTag-interface-in-JSP.jpg?resize=439%2C498&#038;ssl=1\" alt=\"Life cycle of IterationTag and BodyTag interface in JSP\" width=\"439\" height=\"498\" \/><\/a><figcaption id=\"caption-attachment-1717\" class=\"wp-caption-text\">Life cycle of IterationTag and BodyTag interface in JSP<\/figcaption><\/figure>\n<p><!--more--><br \/>\nAs per shown in Above figure, <strong>IterationTag extends Tag interface<\/strong> and adds one new method <strong>doAfterBody()<\/strong> that controls the reevaluation of its body.<\/p>\n<p>doAfterBody() Process body (re)evaluation. This method is invoked by the JSP Page implementation object after every evaluation of the body into the BodyEvaluation object. The method is not invoked if there is no body evaluation.<br \/>\nIf doAfterBody returns <em>EVAL_BODY_AGAIN<\/em>, a new evaluation of the body will happen (followed by another invocation of doAfterBody). If doAfterBody returns <em>SKIP_BODY<\/em>, no more body evaluations will occur, and the doEndTag method will be invoked.<\/p>\n<p>In <strong>BodyTag<\/strong>, There is a new action method: <strong>doInitBody()<\/strong>, which is invoked right after <strong>setBodyContent()<\/strong> and before the body evaluation. This method is only invoked if doStartTag() returns <em>EVAL_BODY_BUFFERED<\/em>.<\/p>\n<p>If EVAL_BODY_BUFFERED is returned, then a BodyContent object will be created (by code generated by the JSP compiler) to capture the body evaluation.<\/p>\n<p><strong>Example of Tag and BodyTag interface:<\/strong><br \/>\nTag Interface:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;up:userPicker multiSelect=\"\u009dtrue\"\u009d \/&gt;\n<\/pre>\n<p>BodyTag interface:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;up:userPicker multiSelect=\"\u009dtrue\"\u009d&gt;\nSelect the User from UserPicker :\n&lt;\/up:userPicker&gt;\n<\/pre>\n<p>Next article :\u00a0<a title=\"Create Custom Tag using Tag Interface\" href=\"https:\/\/jitendrazaa.com\/blog\/java\/how-to-create-jsp-custom-tag-%E2%80%93-using-tag-interface-or-tagsupport\/\" target=\"_blank\">How to Create JSP Custom Tag \u2013 using Tag interface or TagSupport<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Life cycle of JSP BodyTag interface<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[4],"tags":[330],"class_list":["post-1716","post","type-post","status-publish","format-standard","hentry","category-jsp","tag-jsp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1724,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/how-to-create-jsp-custom-tag-using-bodytag-interface-or-bodytagsupport\/","url_meta":{"origin":1716,"position":0},"title":"How to Create JSP Custom Tag \u2013 using BodyTag interface or BodyTagSupport","author":"Jitendra","date":"March 17, 2011","format":false,"excerpt":"Tutorial on How to Create JSP Custom Tag \u2013 using BodyTag interface or BodyTagSupport","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"How to Create Custom Tag in JSP","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/How-to-Create-Custom-Tag-in-JSP.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1720,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/how-to-create-jsp-custom-tag-using-tag-interface-or-tagsupport\/","url_meta":{"origin":1716,"position":1},"title":"How to Create JSP Custom Tag \u2013 using Tag interface or TagSupport","author":"Jitendra","date":"March 17, 2011","format":false,"excerpt":"Tutorial of creating JSP Custom Tag \u2013 using Tag interface or TagSupport in JAVA","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"How to Create Custom Tag in JSP","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/How-to-Create-Custom-Tag-in-JSP.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1712,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/life-cycle-of-jsp-tag-interface\/","url_meta":{"origin":1716,"position":2},"title":"Life cycle of JSP Tag interface","author":"Jitendra","date":"March 17, 2011","format":false,"excerpt":"Life cycle of JSP Tag interface in Java","rel":"","context":"In &quot;JSP&quot;","block_context":{"text":"JSP","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/jsp\/"},"img":{"alt_text":"Life Cycle of Tag Interface","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Life-Cycle-of-Tag-Interface.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2017,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/java-j2ee-interview-questions-1\/","url_meta":{"origin":1716,"position":3},"title":"Java &#8211; J2EE Interview Questions &#8211; 1","author":"Jitendra","date":"April 15, 2011","format":false,"excerpt":"JAVA - J2EE Interview Questions - 1, JAVA - J2EE Interview Questions - 1,custom tag JSP, Externalization , serialVersionUID, difference between interface and abstract class, iterate HashMap","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1707,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/setup-application-to-use-javaserver-pages-standard-tag-libraryjstl\/","url_meta":{"origin":1716,"position":4},"title":"Setup application to use JavaServer Pages Standard Tag Library(JSTL)","author":"Jitendra","date":"March 17, 2011","format":false,"excerpt":"Setup application to use JavaServer Pages Standard Tag Library(JSTL)","rel":"","context":"In &quot;JSP&quot;","block_context":{"text":"JSP","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/jsp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1664,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/jsp\/step-by-step-dwr-application-simple-ajax-in-java\/","url_meta":{"origin":1716,"position":5},"title":"Step by Step DWR Application &#8211; Simple AJAX in JAVA","author":"Jitendra","date":"March 15, 2011","format":false,"excerpt":"Step by Step DWR Application - Simple AJAX in JAVA","rel":"","context":"In &quot;JSP&quot;","block_context":{"text":"JSP","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/jsp\/"},"img":{"alt_text":"How DWR works in Java","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/How-DWR-works-in-Java.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1716","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=1716"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1716\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=1716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=1716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=1716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}