|
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.*" %>
<%
// Ugly scriptlet code that belongs in a model object somewhere
List rows = new ArrayList();
request.setAttribute("rows", rows);
for(int i = 1; i <=12; i++){
List cols = new ArrayList();
for(int j = 1; j <=12; j++){
cols.add(String.valueOf(i * j));
}
rows.add(cols);
}
%>
<html>
<head>
<title>nested forEach tags</title>
</head>
<body>
<table border="1">
<c:forEach var="row" items="${rows}">
<tr>
<c:forEach var="col" items="${row}">
<td>${col}</td>
</c:forEach>
</tr>
</c:forEach>
</table>
</body>
</html>
JspFaq
|