You are incorrectly referring to the value of items
. Taglibs / EL and scriptlets do not use the same variable scope. You basically print columnHeaders.toString()
in the items
attribute and say c:forEach
to iterate over it. Instead, you need to put it in the request area (preferably a servlet) and use EL ${}
usual way:
<% String[] columnHeaders = {"Banana", "Apple", "Carrot", "Orange", "Lychee", "Permisson"}; request.setAttribute("columnHeaders", columnHeaders); %> <c:forEach var="columnHeader" items="${columnHeaders}"> <td> <c:out value="${columnHeader}" /> </td> </c:forEach>
In addition, ${header}
is a reserved EL variable related to the request header map (see implicit objects in EL ), you would need to rename it to another one, for example ${columnHeader}
in the example above.
See also:
Unrelated to a specific problem, table headers should be represented in HTML <th>
, not <td>
.
Balusc
source share