I have a requirement that on click of a hyperlink from a jsp, i want to set a session attribute in the javascript.
On click of the hyperlink there will be 2 parameters passed to the JS function and in that JS function i want to set the 2 variables in session.
Can i achieve this through javascript by using something like session.setAttrbute("key","value");
You can set those attributes through server side. Once you submit the page to the server you may get the required values through request.getParameter() and then set it to the session.
I have a requirement that on click of a hyperlink from a jsp, i want to set a session attribute in the javascript.
On click of the hyperlink there will be 2 parameters passed to the JS function and in that JS function i want to set the 2 variables in session.
Can i achieve this through javascript by using something like session.setAttrbute("key","value");
Thanks
Gurvinder
It may be possible if you submit the two parameters as form fields to the servlet where you read these and set them in the session.
But if you don't want to submit the form, you may pass the parameters through using Ajax call also. Please lemme know if you want to know how to do the same.
i would like to know that. Probably if you can provide me some detailed steps of doing it, it will be great.
But yea just for your info, i want to set the attributes on click of a href in the JS function.
Can anybody help me in this regard of how to set any session attribute through ajax calls.
Please go through the following message chain and suggest me how should i proceed.
I think a tutorial like this will help you get started with AJAX. Once you are able to send the data to the server it's just normal servlet programming stuff.