最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to set a value in JSP session using javascript? - Stack Overflow

programmeradmin2浏览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.

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.

发布评论

评论列表(0)

  1. 暂无评论