{"id":27127,"date":"2021-05-11T23:10:05","date_gmt":"2021-05-12T03:10:05","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/repeattag-java-custom-tag-that-repeats-the-tag-body-a-specified-number-of-times-programming-code-examples-java-j2ee-j2me-applets-and-basic-graphics\/"},"modified":"2021-05-11T23:10:05","modified_gmt":"2021-05-12T03:10:05","slug":"repeattag-java-custom-tag-that-repeats-the-tag-body-a-specified-number-of-times-programming-code-examples-java-j2ee-j2me-applets-and-basic-graphics","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=27127","title":{"rendered":"RepeatTag.java Custom tag that repeats the tag body a specified number of times #Programming Code Examples #Java\/J2EE\/J2ME #Applets and Basic Graphics"},"content":{"rendered":"<pre>\nRepeatTag.java Custom tag that repeats the tag body a specified number of times\n\npackage cwp.tags;\n\nimport javax.servlet.jsp.*;\nimport javax.servlet.jsp.tagext.*;\nimport java.io.*;\n\n\/** A tag that repeats the body the specified\n *  number of times.\n *  &lt;P&gt;\n *  Taken from Core Web Programming Java 2 Edition\n *  from Prentice Hall and Sun Microsystems Press,\n *  .\n *  May be freely used or adapted.\n *\/\n\npublic class RepeatTag extends BodyTagSupport {\n  private int reps;\n\n  public void setReps(String repeats) {\n    try {\n      reps = Integer.parseInt(repeats);\n    } catch(NumberFormatException nfe) {\n      reps = 1;\n    }\n  }\n\n  public int doAfterBody() {\n    if (reps-- &gt;= 1) {\n      BodyContent body = getBodyContent();\n      try {\n        JspWriter out = body.getEnclosingWriter();\n        out.println(body.getString());\n        body.clearBody(); \/\/ Clear for next evaluation\n      } catch(IOException ioe) {\n        System.out.println(&quot;Error in RepeatTag: &quot; + ioe);\n      }\n      return(EVAL_BODY_TAG);\n    } else {\n      return(SKIP_BODY);\n    }\n  }\n}\n\nRepeatExample.jsp\n\n\n&lt;!DOCTYPE HTML PUBLIC &quot;-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN&quot;&gt;\n&lt;!-- \nIllustration of RepeatTag tag. \n\nTaken from Core Web Programming Java 2 Edition\nfrom Prentice Hall and Sun Microsystems Press,\n.\nMay be freely used or adapted. \n--&gt;\n&lt;HTML&gt;\n&lt;HEAD&gt;\n&lt;TITLE&gt;Some 40-Digit Primes&lt;\/TITLE&gt;\n&lt;LINK REL=STYLESHEET\n      HREF=&quot;JSP-Styles.css&quot;\n      TYPE=&quot;text\/css&quot;&gt;\n&lt;\/HEAD&gt;\n&lt;BODY&gt;\n&lt;H1&gt;Some 40-Digit Primes&lt;\/H1&gt;\nEach entry in the following list is the first prime number \nhigher than a randomly selected 40-digit number.\n&lt;%@ taglib uri=&quot;cwp-taglib.tld&quot; prefix=&quot;cwp&quot; %&gt;\n&lt;OL&gt;\n&lt;!-- Repeats N times. A null reps value means repeat once. --&gt;\n&lt;cwp:repeat reps='&lt;%= request.getParameter(&quot;repeats&quot;) %&gt;'&gt;\n  &lt;LI&gt;&lt;cwp:prime length=&quot;40&quot; \/&gt;\n&lt;\/cwp:repeat&gt;\n&lt;\/OL&gt;\n&lt;\/BODY&gt;\n&lt;\/HTML&gt;\n\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10285<br \/> Categories:Programming Code Examples, Java\/J2EE\/J2ME, Applets and Basic Graphics<br \/>Tags:Java\/J2EE\/J2MEApplets and Basic Graphics<br \/> Post Data:2017-01-02 16:04:31<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>RepeatTag.java Custom tag that repeats the tag body a specified number of times package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; \/** A tag that repeats the body the specified * number of times. * &lt;P&gt; * Taken from Core Web Programming Java 2 Edition * from Prentice Hall and Sun Microsystems Press, * . &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=27127\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-27127","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10471,"url":"http:\/\/bangla.sitestree.com\/?p=10471","url_meta":{"origin":27127,"position":0},"title":"RepeatTag.java Custom tag that repeats the tag body a specified number of times","author":"","date":"August 28, 2015","format":false,"excerpt":"RepeatTag.java Custom tag that repeats the tag body a specified number of times package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; \/** A tag that repeats the body the specified \u00a0*\u00a0 number of times. \u00a0*\u00a0 <P> \u00a0*\u00a0 Taken from Core Web Programming Java 2 Edition \u00a0*\u00a0 from Prentice Hall and\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10160,"url":"http:\/\/bangla.sitestree.com\/?p=10160","url_meta":{"origin":27127,"position":1},"title":"ShowMessage.java Servlet that demonstrates the use of initialization parameters.","author":"","date":"August 16, 2015","format":false,"excerpt":"ShowMessage.java\u00a0 Servlet that demonstrates the use of initialization parameters. Remember that, to use this servlet, you have to do three things: \u00a0\u00a0\u00a0 * Put the modified web.xml file in the WEB-INF directory. \u00a0\u00a0\u00a0 * Restart the server. \u00a0\u00a0\u00a0 * Use the registered servlet name (i.e., the URL http:\/\/host\/servlet\/ShowMsg), not the\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26525,"url":"http:\/\/bangla.sitestree.com\/?p=26525","url_meta":{"origin":27127,"position":2},"title":"ShowMessage.java  Servlet that demonstrates the use of initialization parameters. #Programming Code Examples #Java\/J2EE\/J2ME #Servlet","author":"Author-Check- Article-or-Video","date":"April 27, 2021","format":false,"excerpt":"ShowMessage.java Servlet that demonstrates the use of initialization parameters. Remember that, to use this servlet, you have to do three things: * Put the modified web.xml file in the WEB-INF directory. * Restart the server. * Use the registered servlet name (i.e., the URL http:\/\/host\/servlet\/ShowMsg), not the raw servlet name\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10457,"url":"http:\/\/bangla.sitestree.com\/?p=10457","url_meta":{"origin":27127,"position":3},"title":"HeadingTag.java Custom tag that makes use of a tag body","author":"","date":"August 28, 2015","format":false,"excerpt":"HeadingTag.java Custom tag that makes use of a tag body package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; \/** Generates an HTML heading with the specified background \u00a0*\u00a0 color, foreground color, alignment, font, and font size. \u00a0*\u00a0 You can also turn on a border around it, which normally \u00a0*\u00a0 just\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10473,"url":"http:\/\/bangla.sitestree.com\/?p=10473","url_meta":{"origin":27127,"position":4},"title":"IfTag.java, IfConditionTag.java, IfThenTag.java, and IfElseTag.java, Custom tags that make use of tag nesting","author":"","date":"August 28, 2015","format":false,"excerpt":"IfTag.java, IfConditionTag.java, IfThenTag.java, and IfElseTag.java, Custom tags that make use of tag nesting IfTag.java package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; import javax.servlet.*; \/** A tag that acts like an if\/then\/else. \u00a0*\u00a0 <P> \u00a0*\u00a0 Taken from Core Web Programming Java 2 Edition \u00a0*\u00a0 from Prentice Hall and Sun Microsystems\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27115,"url":"http:\/\/bangla.sitestree.com\/?p=27115","url_meta":{"origin":27127,"position":5},"title":"HeadingTag.java Custom tag that makes use of a tag body #Programming Code Examples #Java\/J2EE\/J2ME #Applets and Basic Graphics","author":"Author-Check- Article-or-Video","date":"May 11, 2021","format":false,"excerpt":"HeadingTag.java Custom tag that makes use of a tag body package cwp.tags; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.*; \/** Generates an HTML heading with the specified background * color, foreground color, alignment, font, and font size. * You can also turn on a border around it, which normally * just\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/27127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27127"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/27127\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27127"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}