JSP page to display ArrayList elements using for loop

By | November 16, 2015

An Example which explains how to display ArrayList elements using for loop.

//ArrayList which contains list of student details
<%
ArrayList <studentBean> arl=(ArrayList) request.getAttribute("studentBean");
%>
<table>
<tr>
<th>STUDENTID </th>
<th>FIRST NAME </th>
<th>LASTNAME</th>
<th>CLASS</th>
</tr>
<% try
{
for(int i=0;i<arl.size();i++)
{
<tr>
<td><%=arl.get(i).getstudentID()%></td>
<td><%=arl.get(i).getstudentFname()%></td>
<td><%=arl.get(i).getstudentLname()%></td>
<td><%=arl.get(i).getClass1()%></td>
</tr>
<%}
}
catch(Exception e)
{
System.out.println("Exception");
}
%>
</table>
.




Author: Ravi Bandakkanavar

A Techie, Blogger, Web Designer, Programmer by passion who aspires to learn new Technologies every day. It has been 6 years since I have been publishing articles and enjoying every bit of it. I want to share knowledge and build a great community with people like you.

Suggested read for you:

Did it help? Comment here..