In this JavaEE JSP Tutorial, we will see how to create Foreach loop using the JavaEE JSTL core library.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<!-- Sample 01: Use Core Tags --> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <!-- Sample 02: Let us Check the For Loop --> <c:forEach begin="0" end="10" varStatus="loop" step="2" var="index"> Loop Status :<c:out value="${loop.count}"/> </br> <b>Loop Index :<c:out value="${index}"/></b> </br> </c:forEach> <!-- Sample 03: Note: We can use foreach also, We will see that Later --> </body> </html> |
Categories: JSP