JSP ArrayList is a class and a member of Java Collection Framework.It is the resizable-array and permit all element including the null.
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 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"%>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: