Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing Javascript variable to JSP Session  RSS feed

 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Jimi Parekh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!