Processing Forms in Java

D

dougjrs

Good Afternoon!

I am trying to write a form processor in java that can handle a
select
box with mutiple options selected. The problem that I am having is
when I call request.getParameter("state") I only get the first option
that has been selected. The data is being sent with a POST, but if I
change to a get I have the same problem. The end solution has to be
a
POST because I have to interface with some other software that
requires a POST action.

Also, I had this posted the wrong group before, so sorry if you
already read this.

Thanks,
Doug
 
A

Andrew Thompson

Good Afternoon! ...
Also, I had this posted the wrong group before, so sorry if you
already read this.

Uggh. My bad. I should have read further,
sorry about that.

Andrew T.
 
C

ck

Good Afternoon!

I am trying to write a form processor in java that can handle a
select
box with mutiple options selected. The problem that I am having is
when I call request.getParameter("state") I only get the first option
that has been selected. The data is being sent with a POST, but if I
change to a get I have the same problem. The end solution has to be
a
POST because I have to interface with some other software that
requires a POST action.

Also, I had this posted the wrong group before, so sorry if you
already read this.

Thanks,
Doug

If you are talking about html select, where you can select multiple
items. Try this form like this

<form name="form1" id="form1">
<select name="menu1" size="2" multiple="multiple">
<option>1</option>
<option>2</option>
<option>3</option>
<option>gfsgdg</option>
</select>
</form>

In the servlet you can request it from request object.

request.getParameters("menu1")

Ck
http://www.gfour.net
 
D

dougjrs

That does not seem to do the trick.

Here is the code that I tried:

<form method="POST" action="printer.jsp">
<select class="FORMshrt2" multiple="multiple" SIZE="4"
NAME="Question38592__FORMTEXT22" ID="Question38592__FORMTEXT22">
<option value="AnswerName&=|=X|%%%AnswerValue&=|=X|%%%GDEAnswerValue&=|
TG_SEARCH_ALL=X|???" SELECTED>All</option>
<option VALUE="AnswerName&=|00100=X|%%%AnswerValue&=|00100=X|%%
%GDEAnswerValue&=|=X|???">00100</option>
<option VALUE="AnswerName&=|00603=X|%%%AnswerValue&=|00603=X|%%
%GDEAnswerValue&=|=X|???">00603</option>
</select>
<p><input type="submit" value="Submit" name="B1"></p>
</form>


Here is the code printing the data in printer.jsp:
out.println( " ****** " +
request.getParameter("Question38592__FORMTEXT22") + " ******** ");

Here is what it produces when you select all of the values in the drop
down:
****** AnswerName&=|=X|%%%AnswerValue&=|=X|%%%GDEAnswerValue&=|
TG_SEARCH_ALL=X|??? ********


It only picks up the very first selection.

Did I do somehting wrong?

Thanks,
Doug
 

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,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top