• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Passing Javascript variable to JSP Session

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there!

Hope that this is the right place to post at.

I am trying to pass a javascript variable to another JSP through sessions.

But I am not sure of how to do it.

Thanks in advance!

Regards
Yans Tan
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure about what you mean by "through sessions".
What you could do is set the value into a hidden field before submitting.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can catch the value of Java Script variable to html field and then set the value of that field in session.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Javascript variables exist on the client machine (browser).
JSP session variables exist on the server. If you want to transfer a value from the client to the server you will need to post them to the server in an HTTP request.
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there!

Sorry to bother you people. Thanks for the solution.

This is what I did. Not sure anything wrong with it.

<%
final HttpSession curSession = request.getSession( false );
final String selectedIndex = (String)curSession.getValue(selectedIndexKeyName);
%>

document.frmCity.selCity.selectedIndex = <%= selectedIndex %>

Thanks all!

Regards
Yans
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic