JSTL Core forEach Tag


JSTL Core forEach Tag

JSTL Core forEach Tag is use to execute repeated statement in JSP page and JSTL Core forEach Tag is similar to for loop of java.

Syntax

<c:forEach var="variable" begin="starting_value" end="ending_value">
  ...
 </c:forEach>

Example

<%@ 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>JSTL Examples</title>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
</head>
<body>
 <c:forEach var="i" begin="1" end="5">
    <c:out value="${i}" />
 </c:forEach>
</body>
</html>

Output

1 2 3 4 5






Full-stack web and mobile app development company Contact Us : Skype: indore.webcoder Email: info@w3sparks.com Sales: +91 8085506229