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

Why is request.getParameterValues not working for me?

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a bunch of checkboxes in my JSP and I am just trying to get their values in my servlet.

Here is the JSP code snippet (extra HTML has been removed)....



Here is the code in the servelt...

String[] fileIds = request.getParameterValues("deleteFlag");

For some reason fileIds is null.

Any help would be much appreciated.

Thanks,
Jehan
 
Sheriff
Posts: 67537
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
Are the checkboxes within the form being submitted? Are any of them checked?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get the values of checkboxs
only when they are checked.
 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes and yes. In fact when I use request.getParameter it does get the value of the first checkbox.

Any other suggestions?
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you have misspelt the name of the checkbox or something else. Since, you will get the values of all the checkboxes("That were selected")

The below code is working fine..



If you still can't find what is the problem in you code, copy-paste your code so that others can point out the problems..

HTH
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same thing happening. My case is a little more complicated. I am using innterHTML to create a table that has in the first column (i.e., <td>) an input of checkbox type. I click on submit and the table is generated along with the colum with the checkbox with id="reset". I can put in the input something like: <input type="checkbox" id="reset" onclick="resetvalue(this.value) value="something"> and if I click on the checkbox, it does go to the function I made and show the value that I put in an alert for test purposes. However, String[] reset = getParameterValues("reset") is null if I click on submit again. Any help wuold be appreciated.

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mr.David Shapiro wrote:I have the same thing happening. My case is a little more complicated. I am using innterHTML to create a table that has in the first column (i.e., <td>) an input of checkbox type. I click on submit and the table is generated along with the colum with the checkbox with id="reset". I can put in the input something like: <input type="checkbox" id="reset" onclick="resetvalue(this.value) value="something"> and if I click on the checkbox, it does go to the function I made and show the value that I put in an alert for test purposes. However, String[] reset = getParameterValues("reset") is null if I click on submit again. Any help wuold be appreciated.



David,

Try changing id="reset" to name="reset".

Cheers,
Joe Sondow
 
Mr.David Shapiro
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I changed id to name. I think the magic fix was that I moved the code that generates the <div>targetDiv</div> that receives the table inside the <form> . This caused some issue because the form had some css style to it that got applied t the code in the targetDiv that I did not want, but I worked those out. It looks like I am back in business!

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mr.David Shapiro wrote:Thanks, I changed id to name. I think the magic fix was that I moved the code that generates the <div>targetDiv</div> that receives the table inside the <form> . This caused some issue because the form had some css style to it that got applied t the code in the targetDiv that I did not want, but I worked those out. It looks like I am back in business!



I think the magic fix was changing 'id' to 'name'. In any case, congrats on solving your problem!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic