One of the option which is given as true is:Which of the following statements are correct regarding the forEach tag of JSTL?
The explanation is given as below in answer:The EL code within the body of the tag may refer to the iteration variable but scripting code cannot.
Code: Select all
For example, <%=dept.getName()%> is invalid here:
<c:forEach var="dept" items="${departments}">
<c:out value="${dept.name}"/><br><%=dept.getName()%>
</c:forEach>
I got the output as<% Employee emp = new Employee();
emp.setEmail("abc@gmail.com");
java.util.List<Employee> empList = new java.util.ArrayList();
empList.add(emp);
request.setAttribute("empList", empList); %>
<c:forEach var="emp" items="${empList}" varStatus="status">
Emp email: <%=emp.getEmail()%> <br>
</c:forEach>
.Emp email: abc@gmail.com
Please correct if am wrong.
Thanks,
Sanjay