Rafael,
I agree with Michael that the session can be a good tool to use in this
case, but you probably don't want to use it exclusively. It's irresponsible
for us, as developers to assume that storage is not one of our concerns.
Each of us have a fiduciary responsibility to our companies and customers.
Expense control is (or should be) everyone's concern. Michael may disagree
with me, but whoever is in charge of budgeting your hardware will probably
thank you.
Having said that, deciding whether your shopping cart should store
everything in the session really involves knowing how the cart will be
used - knowing the business. If you expect that, on average, people are
going to add only a few things to their cart at once, you could very easily
store all the data in the session - and putting the form into session scope
might be one good way to accomplish this. If, on the other hand, you expect
that your users will, on average, put tons of items in their shopping carts
(hundreds), putting all of your data into the session would be irresponsible
since your application won't scale very well. In this case, you'd be better
served to store only essential information in the session (such as the
catalog numbers of the items, quantity ... only essential information) and
grab the other data when the user asks to view their shopping cart.
In general, if you know that your dataset is never going to grow to a large
size, and its information you need to track for the users entire session,
session scope is a great place to keep it. If the dataset is expected to
be, or will on average be, quite large, you're better off to store only an
abstraction of the data (the key, for example) in the session and
re-retrieve the details each time the user wishes to view it. If you put
thought into how you construct your queries, and have proper indices
created, the user experience shouldn't suffer much.
Hope that helps!
Eddie Bush
----- Original Message -----
From: "Michael Jouravlev" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>; "Rafael Taboada"
<[EMAIL PROTECTED]>
Sent: Friday, May 27, 2005 1:41 PM
Subject: Re: Shopping Cart
On 5/27/05, Rafael Taboada <[EMAIL PROTECTED]> wrote:
Hi dear folks... I'm programming something like a shopping cart. Do u
know
some way to do that? Or a site where I can find some sample code...
I was thinking about to store beans in session context... But what about
if the bean is so big??? Will there be any problem with the size???
Rafael, I guess you know my opinion on this ;) I prefer to store
stateful objects on server. If it is not in the session, than it is in
the database. But I do not like to pass stuff around in
request/response fields.
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0521-4, 05/27/2005
Tested on: 5/28/2005 12:16:35 PM
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]