Home Tutorial Jsp ArrayList in JSP

 
 

Share on Google+Share on Google+
ArrayList in JSP
Posted on: March 12, 2010 at 12:00 AM
Advertisement
JSP ArrayList is a class and a member of Java Collection Framework.It is the resizable-array and permit all element including the null.

ArrayList in JSP

ArrayList is a class and a member of Java Collection Framework. It is the resizable-array and permit all element including the null. It is similar to Vector but it is unsynchronized. Iterator return the element from the list in proper sequence.

 Description of Program:

In this example there are two file index .jsp and postIndex.jsp. The index.jsp fill take the user input from three different textbox and value post to the postIndex.jsp, which take all  values and placed into the ArrayList object. Through Iterator all the element of the list in shown in proper sequence

index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
First Element
Second Element
Third Element

postIndex.jsp:

<%@page import="java.util.*" contentType="text/html" pageEncoding="UTF-8"%> <% String str1 = request.getParameter("arraylistvalue1");%> <% String str2 = request.getParameter("arraylistvalue2");%> <% String str3 = request.getParameter("arraylistvalue3");%> <% ArrayList alist = new ArrayList(); alist.add(str1); alist.add(str2); alist.add(str3); %> <% Iterator iter = alist.iterator(); %> <%! int x=0; %> <% while(iter.hasNext()){ %> <%}%>
Index Values
<%=++x%> <%=iter.next()%>

Output:

Advertisement

Related Tags for ArrayList in JSP:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com