Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
JSP
Shoppingcart session problem
Harry Bos
Greenhorn
Posts: 1
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello there,
I`m quite new to
jsp
but have to build a simple shoppingcart for practice.
I use this code like below:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" session="true" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <% String dvds[]; dvds = new String[10]; dvds[0] = "Simpsons"; dvds[1] = "Futurerama DVDBOX"; dvds[2] = "The Sopranos DVDBOX"; dvds[3] = "Friends DVDBOX"; dvds[4] = "The Nanny DVD"; dvds[5] = "Southpark"; dvds[6] = "Baantjer"; dvds[7] = "The Xfiles"; dvds[8] = "The mask"; dvds[9] = "Donald Duck DVD"; %> <table width="481" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td height="22" colspan="4" valign="top"><div align="center">Film catalogus: </div></td> </tr> <tr> <td height="21" colspan="2" valign="top">01: <%= dvds[0] %> </td> <td colspan="2" valign="top"><div align="right"> <form name="form1" method="post" action=""> <INPUT TYPE="HIDDEN" NAME="simpsons" VALUE="The Simpsons"> <input type="submit" name="Submit" value="Bestellen"> </form> </div></td> </tr> <tr> <td height="20" colspan="2" valign="top">02: <%= dvds[1] %></td> <td colspan="2" valign="top"><form name="form1" method="post" action=""> <div align="right"> <INPUT TYPE="HIDDEN" NAME="futurama" VALUE="Futurama"> <input type="submit" name="Submit" value="Bestellen"> </div> </form>�</td> </tr> <tr> <td height="20" colspan="2" valign="top">03: <%= dvds[2] %></td> <td width="51"></td> <td width="185"></td> </tr> <tr> <td height="20" colspan="2" valign="top">04: <%= dvds[3] %></td> <td></td> <td></td> </tr> <tr> <td height="20" colspan="2" valign="top">05: <%= dvds[4] %></td> <td></td> <td></td> </tr> <tr> <td height="20" colspan="2" valign="top">06: <%= dvds[5] %></td> <td></td> <td></td> </tr> <tr> <td height="20" colspan="2" valign="top">07: <%= dvds[6] %></td> <td></td> <td></td> </tr> <tr> <td height="20" colspan="2" valign="top">08: <%= dvds[7] %></td> <td></td> <td></td> </tr> <tr> <td height="20" colspan="2" valign="top">09: <%= dvds[8] %></td> <td></td> <td></td> </tr> <tr> <td height="20" colspan="2" valign="top">10: <%= dvds[9] %></td> <td></td> <td></td> </tr> <tr> <td width="193" height="113"> </td> <td width="52"> </td> <td></td> <td></td> </tr> <tr> <td height="35"> </td> <td colspan="2" valign="top"><a href="<%= response.encodeURL("showkar.jsp") %>">Naar het karretje</a> </td> <td> </td> </tr> <tr> <td height="34"> </td> <td> </td> <td></td> <td></td> </tr> </table> <% String dvd1 = request.getParameter( "simpsons" ); session.setAttribute( "theSimpsons", dvd1); String dvd2 = request.getParameter( "futurama" ); session.setAttribute( "futurama", dvd2); %> De volgende item(s) zijn besteld: <br> <%= session.getValue( "theSimpsons" ) %> <br> <%= session.getValue( "futurama" ) %> <br><br> <a href="<%= response.encodeURL("index.jsp") %>">Terug</a> </body> </html>
Now every time i add my first item to the cart it works. But when i add my second item it removes the first item and just adds the second one.
How can i make sure both items will stay in the cart together?
Thanks in advance!
Travis Berthelot
Greenhorn
Posts: 24
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You clear one item when you insert the other. Remember the input fields are in different forms. You really should just use a free E-Commerce program instead of creating your own.
String
dvd1 = request.getParameter( "simpsons" );session.setAttribute( "theSimpsons", dvd1); String dvd2 = request.getParameter( "futurama" );session.setAttribute( "futurama", dvd2);
[ October 30, 2004: Message edited by: Bear Bibeault ]
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Getting search results on same search page
Doubts in jsp
tiles and <sx:autocompleter>
Rounding off $$ amounts
Struts IE render problem
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...