JSP page to display ArrayList elements using for loop

By | June 3, 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>
.
Please Share: Tweet about this on TwitterShare on FacebookShare on Google+Share on RedditPin on PinterestShare on LinkedInDigg thisShare on StumbleUponShare on TumblrBuffer this pageShare on VKEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *