• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding Javascript global Variables to Http Request Session

 
Joe Urbanek
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1669
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked for me, thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic