Solved

sending array as request parameter

Posted on 2003-10-28
4
4,092 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
Comment Utility
>> 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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now