Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

printing values from hashtable on a JSP page

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have created a shopping cart application using jsp and servlets.

I am able to add items to shopping cart.

But I want to show the items on "View Shopping Cart" jsp page in following table format.

Item | Quantity | Price

book1 | 1 | 100
book2 | 2 | 200

Total | 3 | 300

Also I want "updateQuantity()" and "removeFromCart()" functions in "ViewCart.jsp" page.

How should I do it?



The code for the pages is as follows.



----------------------------
ShoppingCart.java




--------------------------------

Product.jsp





 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are using a lot of old and obsolete technology that needs to be updated. Hashtables should be replaced with Map implementations, and your JSP should not contain obsolete Java scriptlets; use the JSTL and EL instead. Please see this JspFaq entry.
 
Sourabh Jahagirdar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks, I will use JSTL and EL.

Just I want to print the output in the table format.

Please help for that.

Thanks.
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To loop over a list, you'd use the JSTL's <c:forEach> action. For each iteration you'd likely create a row (<tr>) of the table. For each individual value in whatever's in the list (an array? a bean?) you'd create a <td> using the EL to fill in the dynamic value.

If we know more about the data you want to show, we could be more specific.

Remember, you need to use a List, array, or Map. Hashtable won't cut it.
 
expectation is the root of all heartache - shakespeare. tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic