Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Processing Forms in Java

Thread view: 
dougjrs@gmail.com - 06 Feb 2007 18:46 GMT
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
Andrew Thompson - 06 Feb 2007 19:05 GMT
On Feb 7, 5:46 am, doug...@gmail.com 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.
ck - 06 Feb 2007 19:16 GMT
On Feb 6, 11:46 pm, doug...@gmail.com wrote:
> Good Afternoon!
>
[quoted text clipped - 13 lines]
> 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
dougjrs@gmail.com - 06 Feb 2007 19:46 GMT
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
Lew - 07 Feb 2007 04:33 GMT
> 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#getParam
eterValues(java.lang.String
)>

- Lew
ck - 07 Feb 2007 07:59 GMT
> doug...@gmail.com wrote:
> > request.getParameter("Question38592__FORMTEXT22") + " ******** ");
[quoted text clipped - 6 lines]
>
> - Lew

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

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.