Session maintanance for Shopping cart
1 posts in topic
Flat View  Flat View

Posted By:   tispl_tispl
Posted On:   Friday, April 20, 2001 12:32 AM

Hi iam writing a servlet with shopping cart.
I have put the Connection con in a session. Now for Statement object (Statement stmt=con.createStatement()) ,should i put this also in session..& also for ResultSet ?
Kindly reply ....

Re: Session maintanance for Shopping cart

Posted By:   Michael_Wax  
Posted On:   Saturday, April 21, 2001 04:13 PM

Are you sure that you want to put the Connection in the session? If you have thousands of sessions existing at one time (not unreasonable for a 15-30 minute session expiration time on a high-traffic store), this would result in thousands of database connections. Also, why hold onto a database connection over the entire session life?

If you are persisting the shopping cart to a database, you only need a database connection for the time it takes to either read from or write to the database. Don't put the Connection and other JDBC objects into the session. You might, instead, want to keep a copy of the cart in the session, so that you don't need to do a database read on each page view. (Of course, this requires that you make sure that another session has not modified the cart since you retrieved it.)

About | Sitemap | Contact