File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing values from hashtable on a JSP page

 
Sourabh Jahagirdar
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • 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





 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic