I called my servlet from Jsp file and here my servlet (i am setting a session name, value) which is used to output data in a div tag of same jsp page who called servlet. i am using that session value as a hidden field in the form submit to jquery, but here, the updated session value is not reached in jquery??
Any solution for the same??
and yes, the jquery fetches the updated session value, if i reload the page before submitting the page..
code
servlet file:
HttpSession session = request.getSession(true);
session.setAttribute("totalpurchase", total);
jsp file:
<form method="post" action="" onclick="check()">
<input type="hidden" value="${sessionScope.totalpurchase}" id="totalpurchase">
</form>
<script>
function checkcart() {
var totalpurchase = document.getElementById('totalpurchase').value;
alert(totalpurchase);
}
</script>