Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp JSP for Each

Related Tutorials


 
 

Share on Google+Share on Google+

JSP for Each

Advertisement
The JSP for Each helps you to iterate over the data in JSP and print the corresponding values on the browser.

JSP for Each

        

The JSP for Each helps you to iterate over the data in JSP and print the corresponding values on the browser.

Understand with Example

The Tutorial illustrate an example from 'JSP for Each'. To understand the example we make use of forEach JSTL tag in jsp. We have used the tag <c:forEach> in order to iterate over the data. The example shows that we are creating a loop to print the natural numbers from 1 to 5 using the attribute begin ="1" and end= "5". The <c.out> print the numbers on the browser.

 

 

Here is the code of foreach.jsp

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<body>
<c:out value="The numbers are: " /><br>
<c:forEach var="num" begin="1" end="5" step="1">
<c:out value="${num}" />
<br>
</c:forEach>
</body>
</html>

Output will be displayed as:

Download Source Code:

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 16, 2009

Related Tutorials

Discuss: JSP for Each  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com