0

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.

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

Comments

0

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 commandlink that sets the hidden element's value before submitting the page.

2 Comments

OP didn't mention anywhere that he is using JSF, so a JSF targeted answer might be confusing to him.
how do I bind a hidden input element to a bean property in a session scope. We are using struts 2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.