Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-16-2005, 07:49 AM   #1 (permalink)
santhini
Registered User
 
Join Date: May 2005
Posts: 1
santhini is on a distinguished road
Shopping cart application using struts

Hi,

I am a Java begininer. I am doing an assignment on shopping cart using Struts framework.
I have a arraylist in my session.
How can i check the size of this arraylist in a jsp-page (with the
jstl taglib)
I want to display a number each time the array size increases.

Here I have pasted the code of the action class I created :

Hashtable item = new Hashtable();
item.put("brand", request.getParameter("brand"));
item.put("color", request.getParameter("color"));
item.put("size", request.getParameter("size"));
item.put("price", request.getParameter("price"));
item.put("shipping", request.getParameter("shipping"));
if (session.getAttribute("cart") == null) {
ArrayList cart = new ArrayList();
cart.add(item);
session.setAttribute("cart", cart);
}

else {
ArrayList cartFromSession = (ArrayList) session.getAttribute("cart");
cartFromSession.add(item);
session.setAttribute("cart", cartFromSession);
}

} catch (Exception e) {
System.out.println("Exception occured");
return mapping.findForward("Failure");
}
return mapping.findForward("SUCCESS");

}
}
How do I check the size of an arraylist in a jsp page with jstl tags. Any help would be greatly appreciated.

Thanks!

Last edited by santhini; 05-16-2005 at 06:01 PM.
santhini is offline   Reply With Quote
Old 05-16-2005, 08:03 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,140
Belisarius is on a distinguished road
Sorry, despite my intentions to, I haven't learned Struts yet. Maybe someone else on the boards knows (I'm the usual answer guy on the Java board here).
__________________
GitS
Belisarius is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 02:35 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting