Link to home
Start Free TrialLog in
Avatar of jeef
jeef

asked on

Using JSP to extract values from a JS file

Background Info
================
I am using Javascript as a shopping cart for a college project.  The script allows users to add items to the shopping cart, and it holds the values in the .JS file, until the user checks out.

Problem Definition
==================
My knowledge of Javascript is horrible, but I am fairly sufficient with JSP.  I want to be able to grab the values submitted in the forms to the JS, and call these values in a JSP so that I can update my database accordingly.

The sequence of events would look like this:

1)User is in catalogue
2)User submits purchases via form
3)HTML file calls .JS file to grab values for further use
4)User confirms order in a JSP page, user inputs id and password to submit order
5)Another JSP will call values from .JS file in order to execute a database Update for the order

I hope this was clear.  Thank you very much for your help.

-- Jeef
Avatar of damonf
damonf

When you are performing client-side javascript operations, the data are not "held in a .JS file" as you say.  Rather, they are held in the browser's memory.  Unless the user submits a form, your server doesn't know about the values.

damonf was correct, you need to redefine your logic.
Avatar of jeef

ASKER

Perhaps I am still mistaken, but...the values are submitted in the form, and then taken by the .JS.  If that is possible.  

If you are correct, however, how would the browser hold the information? Would it be in a cookie file?

Thanks again

--Jeef
ASKER CERTIFIED SOLUTION
Avatar of damonf
damonf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
.js file contains javascript code. javascript is client side language and jsp is server side language.

when you say submit form, it means browser submit form data to server. at the server side, only jsp/servlet can process the form, not the javascript. but you can process data before you submit the form to server by javascript only in browser side.
Avatar of jeef

ASKER

I did some thinking based on what you guys said, and I think I now have a good idea at what I need to do.

Thanks a million.

--Jeef