admin管理员组

文章数量:1426300

Is it possible to set/assign value in session using java script?

Basically, I have few links on my JSP page and on click of those links, I need to set a variable in session.

Is it possible to set/assign value in session using java script?

Basically, I have few links on my JSP page and on click of those links, I need to set a variable in session.

Share Improve this question asked Mar 11, 2011 at 10:31 ajmajm 13.2k59 gold badges169 silver badges241 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

session is server side concept, while javascript plays on browser

  • You can either use ajax on click of those link make a request to server and pass the info. and set it to session @ server

Or

  • If those links on whichuser is going to click is your server's then pass some param with it. and track it at server

The easiest approach is to use a hidden input element bound to a bean property in session scope, and put a JavaScript onclick handler in a mandlink that sets the hidden element's value before submitting the page.

本文标签: javaHow to set a value in JSP session using javascriptStack Overflow