Solved

how to do these?

Posted on 2001-06-21
4
193 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Jpanels and Jframe 8 32
egit plugin on eclipse 8 62
MySqlDump not dumping triggers 1 30
Java exception bubble up 2 17
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

786 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