simpleCoding

I using session concept and selecting values from html page, which i pass it to servlet. Now the coding i need is the "If already selected value is once again chosen then it must print 'this element alreay exist in cart'".Somebody please provide me with that code.
[280 byte] By [nusaira] at [2007-10-2 2:57:44]
# 1
What are you having trouble with specifically. What error messages are you seeing.What code exists in the servlet so far..
nantucketa at 2007-7-15 21:23:39 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2

Thank u so much for ur reply. I tried and got the result i wanted.

Actually, the requirement is,

This program is simple shopping cart example.

There exists two servlets, the first servlet will have items to be selected from the cart, other servlet will use session management procedure and display the selected item from the first servlet.

My problem was,

If an item is been already selected from the first servlet then that must not be allowed to be displayed/printed in the second servlet, i.e to be simple, displayed item cant be once again displayed as the one which is bought again. for eg if "pen" is selected/bought then again he cant select/buy it.

Hope u understood the requirement now.

The logic that i followed is, i got number of items present in cart(1st servlet) then in conditional (IF) statement, i checked whether the size of count(declared as integer) is less than cart size, if not "Item already exist" would be printed. count is incremented with every loop.

Within IF statement i added another IF statement for checking whether the item selected is already there or not , if it is already selected "Item already selected" would be displayed

Thats how i did it.

If u have any better algorithm then please reply back to me with the same.

If u want the coding(reply me) that i've used i 'll send it across.

Bye

nusaira at 2007-7-15 21:23:39 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...