File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Adding attributes into scope automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Adding attributes into scope automatically" Watch "Adding attributes into scope automatically" New topic

Adding attributes into scope automatically

Shashidhar Yarabati
Ranch Hand

Joined: Jun 17, 2007
Posts: 175
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?

Shashidhar<br /> SCJP 1.5<br /> SCWCD 5.0
winay Kumar
Ranch Hand

Joined: Aug 13, 2007
Posts: 34

create an array if you want to add same kind of attributes, then add this array object to session. you can use ArrayList also.

Winay Kumar<br />SCJP 5.0
Stas Fedorov

Joined: May 13, 2008
Posts: 7
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

Joined: Jan 24, 2007
Posts: 27
You need to submit the data using html forms then only you can store to session objects.
Arun kumar

Joined: Apr 22, 2008
Posts: 10
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

Regards,<br /> Arun Kumar<br />----------------------------------<br />SCJP 5.0 86%
I agree. Here's the link:
subject: Adding attributes into scope automatically
It's not a secret anymore!