JSP / EL question: how to pick out a request param for list/combo box, and radio button group

M

mot12345

Please excuse and guide me elsewhere if this is not the right group for
this post.

I cant figure out what the proper JSP / EL syntax is to pick out the
value of a list/combo box and of a radio button group in an HTML form.

I know that for a simple input field, like
<input name="fieldName" type="text" value="70" size="10" maxlength="5">
it's just
${param.fieldName}

But what does it look like for a combo box, say:
<SELECT name="fontSize">
<OPTION value="val1">12pt</option>
<OPTION value="val2">14pt</option>
</SELECT>

and for a group of radio buttons, say:
<input type="radio" name="headers" value="Brief"> Brief
<input type="radio" name="headers" value="Full" checked>Full<br>

Thanks for your help,
Wolfgang,
Santa Barbara, CA
 
J

John C. Bollinger

Please excuse and guide me elsewhere if this is not the right group for
this post.

I cant figure out what the proper JSP / EL syntax is to pick out the
value of a list/combo box and of a radio button group in an HTML form.

I know that for a simple input field, like
<input name="fieldName" type="text" value="70" size="10" maxlength="5">
it's just
${param.fieldName}

But what does it look like for a combo box, say:
<SELECT name="fontSize">
<OPTION value="val1">12pt</option>
<OPTION value="val2">14pt</option>
</SELECT>

As long as the <select> does not allow multiple selections, its just the
same as any other control: ${param.name}, which will give you either
"val1" or "val2" (or possibly nothing if the browser is not
standard-compliant and the user doesn't choose any option).
and for a group of radio buttons, say:
<input type="radio" name="headers" value="Brief"> Brief
<input type="radio" name="headers" value="Full" checked>Full<br>

Again, the same thing: ${param.headers}, which will give you either
"Brief" or "Full". (Since you start out with one option selected, a
browser should not allow the button group to enter a state where no
option is selected, hence you should always get a value. Of course,
"should" != "will".)

This is really about the details of form submission, which are laid out
fairly explicitly in the HTML specs. See
http://www.w3.org/TR/html4/interact/forms.html#h-17.13, for instance.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top