Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Processing Forms in Java

Reply
Thread Tools

Processing Forms in Java

 
 
dougjrs@gmail.com
Guest
Posts: n/a
 
      02-06-2007
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

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      02-06-2007
On Feb 7, 5:46 am, (E-Mail Removed) wrote:
> 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.

 
Reply With Quote
 
 
 
 
ck
Guest
Posts: n/a
 
      02-06-2007
On Feb 6, 11:46 pm, (E-Mail Removed) wrote:
> 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

 
Reply With Quote
 
dougjrs@gmail.com
Guest
Posts: n/a
 
      02-06-2007
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|%%%GDEA nswerValue&=|
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|%%%GDEAnswerVa lue&=|
TG_SEARCH_ALL=X|??? ********


It only picks up the very first selection.

Did I do somehting wrong?

Thanks,
Doug

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      02-07-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> request.getParameter("Question38592__FORMTEXT22") + " ******** ");
> It only picks up the very first selection.
>
> Did I do somehting wrong?


request.getParameterValues()
<http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getParameterValues(java.lang.S tring)>

- Lew
 
Reply With Quote
 
ck
Guest
Posts: n/a
 
      02-07-2007
On Feb 7, 9:33 am, Lew <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > request.getParameter("Question38592__FORMTEXT22") + " ******** ");
> > It only picks up the very first selection.

>
> > Did I do somehting wrong?

>
> request.getParameterValues()
> <http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.ht...)>
>
> - Lew


I am sorry about the incorrect method I posted previously. As Lew
mentioned "request.getParameterValues()" should work.

--
Ck
http://www.gfour.net

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
Post-Processing RAW vs Post-Processing TIFF Mike Henley Digital Photography 42 01-30-2005 08:26 AM
processing forms program =?Utf-8?B?QmVueQ==?= ASP .Net 6 10-06-2004 01:05 AM
Question: processing HTML, re-write default processing action of many tags Hubert Hung-Hsien Chang Python 2 09-17-2004 03:10 PM
Web Forms VS Windows Forms Brendan Miller ASP .Net 2 08-11-2003 09:05 PM



Advertisments