updating session value in servlet but the same session in jsp page is not updated
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello all..
I am developing a e-commerce college project, here i add the items in the cart(a div tag in the jsp page) via servlet by creating sessions,
flow control:
shopping jsp (when user wants to add an item in the cart) --> item servlet (which is used to create session and synchronized it) --> cart servlet(which is used to add items in the arraylist and show them in the shopping.jsp's div tag + it also sets the total purchase amount in the session variable "totalpurchase")
now after that user wants to proceed to checkout, here i use the onclick event to check the minimumshopping amount must be less than the totalpurchase (totalpurchase which i had setted in the session),but my jsp page is unable to rechognise the updated value of the totalpurchase,
yes, if i reload the page, it rechognises the new updated value of the totalpurchase?
but i want it to rechognise the updated total purchase value, without reloading he jsp page..
and solution for that??
or any other good method to do the same?? please help
I am developing a e-commerce college project, here i add the items in the cart(a div tag in the jsp page) via servlet by creating sessions,
flow control:
shopping jsp (when user wants to add an item in the cart) --> item servlet (which is used to create session and synchronized it) --> cart servlet(which is used to add items in the arraylist and show them in the shopping.jsp's div tag + it also sets the total purchase amount in the session variable "totalpurchase")
now after that user wants to proceed to checkout, here i use the onclick event to check the minimumshopping amount must be less than the totalpurchase (totalpurchase which i had setted in the session),but my jsp page is unable to rechognise the updated value of the totalpurchase,
yes, if i reload the page, it rechognises the new updated value of the totalpurchase?
but i want it to rechognise the updated total purchase value, without reloading he jsp page..
and solution for that??
or any other good method to do the same?? please help
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Try AJAX to update the purchase amount in your JSP page.
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
yes, via ajax.. i will work..
but it is not look like a good work, to refresh the page after every say n seconds..??
but it is not look like a good work, to refresh the page after every say n seconds..??
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I don't think updating the page should be necessary.
What does this onclick handler do? Obviously it must access some servlet to do this checking...?
now after that user wants to proceed to checkout, here i use the onclick event to check the minimumshopping amount must be less than the totalpurchase (totalpurchase which i had setted in the session),but my jsp page is unable to rechognise the updated value of the totalpurchase,
What does this onclick handler do? Obviously it must access some servlet to do this checking...?
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
this onclick handler, sends the hidden parameters like totalpurchase and minimumorder (amount) to javascript, which checks that totalpurchase must not be smaller than minimumorder to proceed to final checkout..
Ulf Dittmer
Rancher
Posts: 43081
77
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
So, since you said "my jsp page is unable to rechognise the updated value of the totalpurchase", it sounds as if there is a bug in the JavaScript code?
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
jsp file
servlet file
yes, its unable to rechognise the updated value of the totalpurchase , since it only rechognise the updated value, after a page refresh..
servlet file
yes, its unable to rechognise the updated value of the totalpurchase , since it only rechognise the updated value, after a page refresh..
Ulf Dittmer
Rancher
Posts: 43081
77
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I don't think I understand the flow. The hidden value obviously can only reflect what was put into the cart before the current page was displayed - you'd need to update that with whatever was added to the cart on the current page. Is that the problem? Or are you saying that the hidden field does not have the correct value to begin with?
posted 11 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
ok, thanks for trying to understand..
actually i have a jsp file contains cart (as a div tag) and many other div tags in which the item to be added in the cart are placed.., now when user clicks on the item , in the backend the control will go to the servlet in which session is created and synchronized then the control moves to other servlet which adds the item in the arraylist (Backend - cart ) and show those items in the jsp page's div tag(UI - cart) and also set a session variable,value (totalpurchase) ,
UI (JSP file)
now after this, when user saw the item is added in the cart, he wants to proceed to final checkout, when user clicks on the final checkout button(after that div tag in the JSP page), i want the ( updated ) value of that session variable ( totalpurchase ) ,
Error: totalpurchase value is "0" , that is, it is not changed according to the new value updated by the servlet.
and yes, if i refresh my page at this stage, then it catches the correct value..
actually i have a jsp file contains cart (as a div tag) and many other div tags in which the item to be added in the cart are placed.., now when user clicks on the item , in the backend the control will go to the servlet in which session is created and synchronized then the control moves to other servlet which adds the item in the arraylist (Backend - cart ) and show those items in the jsp page's div tag(UI - cart) and also set a session variable,value (totalpurchase) ,
UI (JSP file)
now after this, when user saw the item is added in the cart, he wants to proceed to final checkout, when user clicks on the final checkout button(after that div tag in the JSP page), i want the ( updated ) value of that session variable ( totalpurchase ) ,
Error: totalpurchase value is "0" , that is, it is not changed according to the new value updated by the servlet.
and yes, if i refresh my page at this stage, then it catches the correct value..
posted 1 year ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
were you ever able to get solution. I have encountered the same situation. Cart value is reduced in a servlet. But when returned back to JSP page from servlet , the new value is not shown....
If I refresh the JSP page or go to another page, then the new value is updated.
Thank you
If I refresh the JSP page or go to another page, then the new value is updated.
Thank you
Sri Band
Greenhorn
Posts: 2
posted 1 year ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Nevermind... I set the correct value in the request.getSession().setAttribute(xxxx) and the updated value is shown on return to JSP page
| We noticed he had no friends. So we gave him this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |








