Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Shopping cart & calculate the total price  RSS feed

 
Minghuan Xie
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, I am making a shopping cart web, but some problems I meet about how to calculate the total price


I use ajax in product list web and if I choose one product , it will send the Id that I read from MySql to servlet and use session to save it . and I click the button jump to the cart, the page cart.jsp will read information
from session ,and find product information from mysql by id , now my question is where I calculate the total price, servlet or jsp?
 
es kranthi
Ranch Hand
Posts: 32
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To show the total price simply use Javascript inside your JSP and to process the total price use your servlet always.

You can use Servlet if you have some internal calculations like taxes,handling charges,shipping charges for individual locations or if you need some third party price to be fetched before caluculating the total price.

If its a simple calcualtion like sum of all the products then you can use simple javascript and just show a label (div) which tells the total price.
In the servlet just calculate the total price and process.
 
Minghuan Xie
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your explain, that almost solve my problem .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!