Hi everybody, A JSP is converted to a servlet, and a response is sent as a html file. If I�m using a JSP to send the response can I send variables (like customer�s purchase amount so far and customer�s balance amount) along with the html content in the response and then use it to alert the customer if he /she purchases more items and his/her purchase amount is greater than the balance amount.
Originally posted by Poonam Kadu: If I�m using a JSP to send the response can I send variables ...
Depends what you mean by "variables".
If you mean Java variables, then of course not. What would deal with them on the client side? Remember, from the point of view of the browser, it's getting an HTML page just like any other. The fact that it was generated with JSP is moot.
Thanks for your explanation.Now I�ve got a clear idea of what a browser understands and what it doesn�t . But now I�ve another problem� When the user clicks on the checkout button for the first time , if purchase amount is greater than balance then the alert message �Insufficient Balance� is displayed. Seeing this alert message the user modifies his/her purchase requests so that purchase amount is less than balance. To modify a (purchase/sell)request , Modify.jsp and SaveChanges.java servlet are used. SaveChanges.java makes the required changes to the Requests object(it�s a Model, shoppingcart kind of object) and forwards the httprequest to DisReq.jsp
When the user clicks on checkout button(for the 2nd time) after modifying purchase requests, the browser uses the old values of script variables puramt and balamt (used during first checkout) to check whether purchase amount< balance
<%--DisReq.jsp displays the Buy/Sell stocks requests so far placed by the user--%> <%--Allows the user to remove or modify a desired request, place more requests and checkout--%>
Originally posted by Poonam Kadu: <%Requests req=(Requests)session.getAttribute("SHARES"); req.calPurchase();%> <%--Requests.java is a model (MVC) which acts like a shopping cart req.calPurchase() calculates the purchase amount--%>