Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding attributes into scope automatically

 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following requirement.

I have a list of check boxes(say 100 check boxes) in my JSP page. Each check box specifies different book name. The user clicks some check boxes and clicks the Add button.

Then the list of book's (checked by the the user through check boxes) should get automatically added into my session attribute.

So that I can use the session.

Is it possible(in any way) to add bunch of attributes into session(or any scope) automatically?
 
winay Kumar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

create an array if you want to add same kind of attributes, then add this array object to session. you can use ArrayList also.
 
Stas Fedorov
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have same name for checkboxes, but different values (booknames),
you can use

In this case, if you have an array String[] name_of_checkboxes, you will get it filled automatically, after submitting.
 
prabakaran perumal
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to submit the data using html forms then only you can store to session objects.
 
Arun kumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using AJAX to call a servlet and send the checked values as parameters to the servlet and store it in the session . So that when you goto the next jsp or servlet you can directly access them
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic