Solved

how to do these?

Posted on 2001-06-21
4
192 Views
Last Modified: 2010-03-31
hi
I'm working on a shopping cart and i'm facing the following problem.could anybody help.
i have a shop cart which shows some lists of products in a table .at the beginning of each row I have included a checkbox which the purchaser can click to indicate if he wants to delete it from the shopcart.how do i handle
A
1.if user clicks one checkbox and then presses a button  to delete.
 2.if the user clicks on more than one rows of products and clicks the delete button
B.After deletion the remaining items in the shopcart should be shown.

I'm working in servlets.the shopcart fethches data from a temporary database table which is updated on every addition/deletion.
could these things be done without major hassles through servletsand jdbc
0
Comment
Question by:ManojKumar
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
superschlonz earned 100 total points
ID: 6214065
You could use the putValue() and getValue() methods of HttpSession.
For example you could do it like this:

If the session is new add a Vector to it for storing items:
HttpSession sess = request.getSession();
if( sess.isNew() ) {
  sess.putValue( "items", new Vector() );
}

The if the user wants to add an item you add the item to the vector:
Item item = new Item( ... );  /your class for storing item infos
HttpSession sess = request.getSession();
Vector items = (Vector)sess.getValue( "items" );
items.addElement( item );

Or showing the iterms:
HttpSession sess = request.getSession();
Vector items = (Vector)sess.getValue( "items" );
for( int i=0; i<items.size(); ++i ) {
  Item item = (Item)itmes.elementAt(i);
  // print item here
}

When the customer clicks 'order' you store all the items in the database with
some additional infos, for ex. customer ID or name and addres or...
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 6214075
If you use this session variables you won't get some zombie items in the
database when the customer didn't order, because the session gets a
timeout and the items in the session will be discarded.
0
 

Expert Comment

by:Nachiap
ID: 6215996
what you can do is just keep all the product details in one vector (probaly you can put it in some bean so that vector of productbean)
along with product id.
In the page give the check box name the same (ex : chk)& value as the product id (ex : productBean.getProductId()).
when that page is submited with some check boxes checked for deletion then u can get all the product ids to deleted
(tho request.getParameterValue())
now u can loop tho that & u can just remove that from the vactor in session.
finally update all the values in session to data base..

0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 8950877


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


--  Points to superschlonz


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now