Displaying ArrayList in JSP
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Swati_Kumar
Posted On:   Thursday, October 20, 2005 07:29 PM

Hi, I would like to do the following: 1) Put a ArrayList of strings in session. 2) Display the values in the ArrayList on a JSP page (Not in a List Box. Just Display it on the screen.) Could someone send me the sample code for this.,BR. Lets assume that I put the ArrayList in session using: ArrayList myArrayList = new ArrayList(); myArrayList.add("Hello"); session.setAttribute(MY_ARRAY_LIST, myArrayList); Now I want to display Hello on my JSP. How do I do that. I am pretty new working with Struts. Thanks -Joe    More>>

Hi,

I would like to do the following:

1) Put a ArrayList of strings in session.
2) Display the values in the ArrayList on a JSP page (Not in a List Box. Just Display it on the screen.)

Could someone send me the sample code for this.,BR.

Lets assume that I put the ArrayList in session using:


ArrayList myArrayList = new ArrayList();

myArrayList.add("Hello");

session.setAttribute(MY_ARRAY_LIST, myArrayList);


Now I want to display Hello on my JSP.
How do I do that.
I am pretty new working with Struts.

Thanks
-Joe

   <<Less

Re: Displaying ArrayList in JSP

Posted By:   WarnerJan_Veldhuis  
Posted On:   Friday, October 21, 2005 03:08 AM






or without taglibs:

<%
List bla = (ArrayList) request.getSession().getAttribute(MY_ARRAY_LIST);
for( Iterator i = bla.iterator() ; iter.hasNext(); ) {
out.println( (String) iter.next() );
}
About | Sitemap | Contact