Solved

sending array as request parameter

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Multi-threading long-running processes can have a significant increase in overall performance and drastically decrease over time it takes for a process to complete. Unfortunately, not all applications support native multi-threading, some by design a…
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

707 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