Solved

sending array as request parameter

Posted on 2003-10-28
4
4,094 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Data breaches are on the rise, and companies are preparing by boosting their cybersecurity budgets. According to the Cybersecurity Market Report (http://www.cybersecurityventures.com/cybersecurity-market-report), worldwide spending on cybersecurity …
Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

832 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