Javatpoint Logo
Javatpoint Logo

Iteration using JSP Custom Tag

We can iterate the body content of any tag using the doAfterBody() method of IterationTag interface.

Here we are going to use the TagSupport class which implements the IterationTag interface. For iterating the body content, we need to use the EVAL_BODY_AGAIN constant in the doAfterBody() method.

Example of Iteration using JSP Custom Tag

In this example, we are going to use the attribute in the custom tag, which returns the power of any given number. We have created three files here

  • index.jsp
  • PowerNumber.java
  • mytags.tld
index.jsp

PowerNumber.java

mytags.tld

Looping using Iteration Tag (creating tag for loop)

Let's create a loop tag that iterates the body content of this tag.

File: index.jsp
File: mytags.tld
File: Loop.java
File: web.xml

Output

Iteration Tag in JSP







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA