• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using JSP to copy javascript value into session attribute  RSS feed

 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In one of my JSP pages, I have a javascript function, that gets a String value from a control,for example a button.The button's onclick() event calls this javascript function



Now my question is,how can I possibly store this variable,"aName" in a session attribute using JSP?
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Submit the form. Retrive value using request.getParameter() and put the same in session.
 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi chetan...it is without submitting the entire form...managed to implement it by using a servlet and AJAX...
thanks

vijai
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vijaishanker bala:
hi chetan...it is without submitting the entire form...managed to implement it by using a servlet and AJAX...
thanks

vijai


No idea about Ajax.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the server side (your JSP/Servlet code), a request made by an AJAX client is no different from any other GET or POST request.
You would use request.getParameter("{param name}") to retrieve the value.
You would then use session.setAttribute("{param name}", variable) to bind it to session.

If you need more help, with the AJAX end of things, ask that this thread be moved to the HTML/Javascript forum as AJAX clients are typically coded in Javascript.
 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben Souther, I have managed to solve this using AJAX and servlets...calling a servlet from the JSP(using javascript and AJAX), passing parameters to the servlet, and letting the servlet use those parameters and set it as session attributes...I guess,I should have posted this in the java scripts section but little did I know,that this would be the way to solve this problem when I posted it...

Thanks

Vijai
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!