• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Selecting records in a jsp and displaying selected in another

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I display a few records on "one.jsp" with a checkbox in the first column.
The checkboxes have the same name while id gets incremented.
The data is in an ArrayList(total) which contains Beans so the rows get the bean.getXXX().
On submit of the SELECT button, i intend to store the selected records(beans of total) into another arrayList(selected).

I have looked up previous posts to find a solution to my problem suggesting the use of request.getParameterValues("checkBoxName") to get the selected checkboxes.

At the point where i check for action in my servlet i try to get the checked values but it is null.Am i missing anything abt scope(request/session) or something else needs to be done in one.jsp or two.jsp?
String[] checkedValues =req.getParameterValues("SelBox");
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can let us know what did you set for the checkbox values? If it's printing null it's not passing in the values from the checkboxes. Also can we see the whole code?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Am i missing anything abt scope(request/session) or something else needs to be done in one.jsp or two.jsp?



Request and session scopes have nothing to do with submitted values.

By the way, about is spelled about, not "abt".


String[] checkedValues =req.getParameterValues("SelBox");



If your checkbox elements are named "SelBox", this will return an array of the values for any checked checkboxes. Note, checkboxes that are not checked will return no value.

If you are not getting any values for checked checkboxes, there may be something wrong with the structure of your form or form elements.
[ November 22, 2005: Message edited by: Bear Bibeault ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic