Using JSP to extract values from a JS file

Posted on 2003-03-24
Medium Priority
Last Modified: 2012-05-04
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
Question by:jeef
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2

Expert Comment

ID: 8197780
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.

LVL 14

Expert Comment

ID: 8199994
damonf was correct, you need to redefine your logic.

Author Comment

ID: 8200199
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

damonf earned 300 total points
ID: 8202496
The ".JS file" is simply the source code for the javascript programs.  It gets interpreted by and run by the browser.  That is its only function.

When code runs on the browser, information is held in a variety of ways.  Just think of your browser as another code platform.  It has memory and storage, although the "storage" is pretty limited because of the sandbox architecture for the browser...you aren't generally allowed to touch the end user's disk drive.  You can store variables in memory, but they will only persist until the next form submission (unless your code is running from a frame that doesn't reload).  Storing data in cookies is one option, but this is not recommended for large amounts of data.  Another option is to write out your data to form fields that get submitted.

I think what you want to do is submit values to the server and hold them in session variables until the user checks out.  
LVL 14

Expert Comment

ID: 8203111
.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.

Author Comment

ID: 8207870
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.


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question