Solved

sending array as request parameter

Posted on 2003-10-28
4
4,096 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

A hard and fast method for reducing Active Directory Administrators members.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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