<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> ex06_forEach.jsp

forEach

<%-- # : for 문 대체하는 태그. - --%>

일반 forEach

i : ${i}

향상된 forEach

<% String[] colors = { "red", "green", "blue", "orange", "black" }; %> ${color }

varStatus

count : ${check.count } index : ${check.index } current : ${check.current } first : "> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> ex06_forEach.jsp

forEach

<%-- # : for 문 대체하는 태그. - --%>

일반 forEach

i : ${i}

향상된 forEach

<% String[] colors = { "red", "green", "blue", "orange", "black" }; %> ${color }

varStatus

count : ${check.count } index : ${check.index } current : ${check.current } first : "> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> ex06_forEach.jsp

forEach

<%-- # : for 문 대체하는 태그. - --%>

일반 forEach

i : ${i}

향상된 forEach

<% String[] colors = { "red", "green", "blue", "orange", "black" }; %> ${color }

varStatus

count : ${check.count } index : ${check.index } current : ${check.current } first : ">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="<http://java.sun.com/jsp/jstl/core>" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex06_forEach.jsp</title>
</head>
<body>
	<h1>forEach</h1>
	<%--
		# <c:forEach> : for 문 대체하는 태그.
		- <c:forEach var="변수명" begin="시작값" end="마지막값" step="증가값"/>
		  <c:forEach var="변수명" items="배열 or 컬렉션"/>
	--%>
	<h2>일반 forEach</h2>
	<c:forEach var="i" begin="1" end="5" step="1">
		<p> i : ${i}</p>
	</c:forEach>
	
	
	<h2> 향상된 forEach </h2>
	<%
		String[] colors = { "red", "green", "blue", "orange", "black" };
	%>
	<c:forEach var="color" items="<%=colors %>">
		<span style="color: ${color};">${color }</span>
	</c:forEach>
	<br>
	
	<h2>varStatus</h2>
	<table border="1">
		<c:forEach var="color" items="<%=colors %>" varStatus="check">
			<tr>
				<td> count : ${check.count } </td>
				<td> index : ${check.index } </td>
				<td> current : ${check.current } </td>
				<td> first : ${check.first } </td>
				<td> last : ${check.last } </td>
			</tr>
		</c:forEach>
	</table>
	<br>
	
	<h2> 국 가 입 력 확 인 </h2>
	<c:forEach var="checkbox" items="${paramValues.nations}">
		<p>${checkbox }</p>
	</c:forEach>
	<br>
	
	<h2>구구단</h2>
	<c:set var="dan" value="${param.dan }"/>
	<p><strong>${dan } 단</strong></p>
	<table border="1">
		<c:forEach var="su" begin="1" end="9" step="1">
			<tr>
				<td>${dan } * ${su }= ${dan*su }</td>
			</tr>
		</c:forEach>
	</table>
</body>
</html>