get "all" HTML form parameters in servlet

S

spb

I have an HTML form which on submission I need to insert into the
database. I am using a servlet and using the get parameter names and
values. However, if none of the options of a checkbox are selected then
I do not even get the parameter name. I definitely need to know the
parameter names even if they are not selected. Also, if possible I want
to be able to get all the checkbox values irrespective of whether they
were checked ot unchecked (maybe with some check flag or some way).
I am stuck and need some help asap. Appreciate any suggestions or help.

Thanks.
 
T

Tor Iver Wilhelmsen

spb said:
I definitely need to know the parameter names even if they are not
selected. Also, if possible I want to be able to get all the
checkbox values irrespective of whether they were checked ot
unchecked (maybe with some check flag or some way).

Then use your own list of fields that you check against (a "form
model" if you like - that was a major hint by the way) instead of
using the enumeration of fields soming in the request. The browsers
will not change their specified and standard behavior.
 
L

Lisa

spb said:
I have an HTML form which on submission I need to insert into the
database. I am using a servlet and using the get parameter names and
values. However, if none of the options of a checkbox are selected then
I do not even get the parameter name. I definitely need to know the
parameter names even if they are not selected. Also, if possible I want
to be able to get all the checkbox values irrespective of whether they
were checked ot unchecked (maybe with some check flag or some way).
I am stuck and need some help asap. Appreciate any suggestions or help.

Thanks.

The browser doesn't send the data in this case. You can put in some
javascript to detect this condition and force a value, or provide a new
hidden value that tells you this.
 
Y

yog

There is a simple Solution for this.
FIRST in the post method submit the form ot the same page.
when you submit to the same page u acn get what values are selected and
what values are not.when u get this then pass these values to the next
page.Now as u r on the same page u also know the unselected values
..pass them also to the next page by using request.setAttribute();
Now u know that u have come to the page second time(YOU COULD DO THIS
BY KEEPING THE VARIABLE AND UPDATING IT)
then forward it to the next page.
Now on the next page u will have all the selected as well as the
unselected values
Hope this solves the pblm.If not let me know

Thanks
Yogesh
 
L

Lisa

yog said:
There is a simple Solution for this.
FIRST in the post method submit the form ot the same page.
when you submit to the same page u acn get what values are selected and
what values are not.when u get this then pass these values to the next
page.Now as u r on the same page u also know the unselected values
.pass them also to the next page by using request.setAttribute();
Now u know that u have come to the page second time(YOU COULD DO THIS
BY KEEPING THE VARIABLE AND UPDATING IT)
then forward it to the next page.
Now on the next page u will have all the selected as well as the
unselected values
Hope this solves the pblm.If not let me know

Thanks
Yogesh
Can you use english words please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top