Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

servlet and checkbox state

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
suppose there are 5 checkboxes and a submit button which goes in servlet.now how to known which checkboxes are checked and which are not from the servlet
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to put name and value for each checkbox.
Go through a HTML tutorial real quick.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only the values from the checkboxes which are checked will be sent to the servlet. Retrieve the values using getParameterValues(String).
For example, given this snippet of HTML
<form>
<input type=checkbox name=Test value=1>One
<input type=checkbox name=Test value=2>Two
<input type=checkbox name=Test value=3>Three
</form>
If the user checked the boxes labelled One and Three, then this code in your servlet
String[] values = req.getParameterValues("Test");
will result in values being a 2 element String array such that one element will be "1" and the other element will be "3".
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic