So I am getting an ArrayList of StudentBeans
from the session, and I want to iterate through each StudentBean
and get the values, but for some reason, the elements of ArrayList are not being stored in the variable as I am getting only one 0 arg constructor StudentBean
. Can you tell me where is my mistake?
<jsp:useBean
id="list"
class="java.util.ArrayList"
type="java.util.ArrayList"
scope="session">
</jsp:useBean>
<jsp:useBean
id="student"
class="com.foo.bar.beans.StudentBean"
type="com.foo.bar.beans.StudentBean"
scope="page">
</jsp:useBean>
<table>
<tr>
<th>#</th>
<th>Name</th>
<th>ID</th>
<th>Grade</th>
</tr>
<c:forEach items="${list}" var="student">
<tr>
<td>
x
</td>
<td>
${student.name}
</td>
<td>
${student.id}
</td>
<td>
${student.grade}
</td>
</tr>
</table>
</c:forEach>