Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why is request.getParameterValues not working for me?

 
Jehan Jaleel
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the checkboxes within the form being submitted? Are any of them checked?
 
Lin Hung Ju
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Srikanth Nutigattu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • 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
 
Mr.David Shapiro
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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.

 
Joe Sondow
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • 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
  • 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!

 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic