Solved

sending array as request parameter

Posted on 2003-10-28
4
4,095 Views
Last Modified: 2009-11-27
i have multiple selection drop down in my jsp. it has some items, user can select items to delete them. when user clicks save after selecting some items i have to send  both selected and non selected items to servlet.

i'm planning to  put selected items in array and nonselected items in another array and send as request parameters to servlet

is there any way to send these arrays as request parameters other than being dropdowns or checkboxes
0
Comment
Question by:soft_techy
4 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 125 total points
ID: 9639287
>> i have multiple selection drop down in my jsp.
I don't think you can make multiple selection in drop down box. so I assume you are using multi-select box.

if you simply use form post, those selected items will be sent and you'll get it as an array using request.getParameterValues( "selectedItems" ). To handle those nonselected items, you'll actually have to put all available items in hidden fields. e.g. repeat all your available items as
<input type=hidden name=allItems value="item1">
<input type=hidden name=allItems value="item2">
...
<input type=hidden name=allitems value="itemN">
then you can use request.getParameterValues( "allItems" ) to get it.

I believe you know get nonselected items once you know all items and selected items.
0
 
LVL 3

Expert Comment

by:krispols
ID: 9648434
hello soft_techy,

You could use the following concept:
1/The user call a servlet
2/ a) The servlet check on the session if the list allready exist.
    b) If not or if the content must change, then the servlet build a list that you will use to build your listbox, and put it on the session.
3/ In your jsp you use the list to build the list box.
4/ In the servlet called by the jsp, you get the list from the session and the selected items from the request.

regards
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 48
gZip compression filter 2 174
runtime exception 2 42
running on tomcat not jboss eap 7.0 3 19
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
Riverbed Technology's webinar discusses networking for the cloud era with simplified SD-WAN cloud connectivity.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question