• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 67746
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: 67746
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic