File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Adding Javascript global Variables to Http Request Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Adding Javascript global Variables to Http Request Session" Watch "Adding Javascript global Variables to Http Request Session" New topic
Author

Adding Javascript global Variables to Http Request Session

Joe Urbanek
Greenhorn

Joined: Jan 31, 2005
Posts: 15
I have a JSP that includes the following javascript functions to generate a swap list. The Options are 2 collections, hostList and targetHostList which are retrieved from a database on the server and loaded into the request session. The User makes selections and these selecteds are stored in Global Javascript variable selectedOptions. How can I make the javascript variable selectedOptions accessable to the Servlet when it is posted?

Here is the code which I am trying to accomplish this with:
(Java Script Swap List):



Your assistance is greatly appreciated
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
The only way to pass values to Java code would be via a request parameter.

Put a hidden field on the page, and populate it with a comma separated list of selected items.
Your Servlet code can then retrieve that String, parse it and determine the selected options.
Joe Urbanek
Greenhorn

Joined: Jan 31, 2005
Posts: 15
That worked for me, thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding Javascript global Variables to Http Request Session
 
Similar Threads
Undefined is null or not an object
Search A String and....
call Action from javascript
Object Required error in Javascript.
moving items from one html:select to another