• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

commons fileupload mutlipart/data-form, extracting values from the checkboxes

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

i have a JSP with a multipart/data-form which has a combination of textfields, file upload field and checkboxes.
I'm currently stuck at how to get the values from the different checkboxes to put them in an array.

here's the part in my servlet i use to extract the formfields and their input and put them in a map.



 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, a Checkbox will return only it's status, right? Selected / Deselected. So you want to record these states in a array? That would be quite easy.

Assuming, you will parse them inside the while loop, first, do your test/validations to locate a checkbox (in case you have other types of items too), then get it's state with .isSelected() method, and store the result in a simple boolean array, which you can define just before entering the loop ( private boolean[] bools = new boolean[10]; ). This way, you will store all the states.

PS: If this is not what you intended, please give a couple more details
 
Ranch Hand
Posts: 326
Android Mac OS X Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at http://www.java2s.com/Tutorial/Java/0400__Servlet/ServletFormProcessorCheckBox.htm

When checking a input with type=checkbox, you are returning the value of the input in a String[] with the key of the checkbox group.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic