Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

passing an array and retrieving that array

Posted on 2003-11-06
9
Medium Priority
?
562 Views
Last Modified: 2010-04-01
i already have values in my array. the problem is how can i pass it to another page and how will i retrieve it from that page.
 e.g. i have an array arr[]
how will i pass it and then retrieve it.thanks. a code will be much appreciated.

can i use this?
<input type="hidden" name="darray" value="arr">

and then get it in another page like this:
String[] myarray = request.getParameterValues("darray");

thanks in advance.
0
Comment
Question by:tizay
[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
9 Comments
 
LVL 3

Expert Comment

by:applekanna
ID: 9698675
<input type="hidden" name="darray" value="1">
<input type="hidden" name="darray" value="2">
<input type="hidden" name="darray" value="3">
<input type="hidden" name="darray" value="4">

and get it as

String[] myarray = request.getParameterValues("darray");
0
 
LVL 3

Expert Comment

by:applekanna
ID: 9698682
I am not sure if they will arrive in the same order if you are very particular about that.

Can you also explain what you need to send across so that we can see if there is a better way of doing it.
Hope this helps

Cheers!
0
 
LVL 1

Expert Comment

by:yapsing
ID: 9699134
i need to know: are u inserting all the parameters into a db?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 15

Expert Comment

by:jimmack
ID: 9702011
If your "arr" is in a JSP, and you want this to be available on another page in one session (eg. if the data is to follow the user to the next page), then just store it in a session variable:

Source page
-----------------

<%
session.setAttribute("arr", arr);
%>

Target page
-----------------
<%
String[] arr = session.getAttribute("arr");
%>
0
 

Accepted Solution

by:
mrishmawy earned 80 total points
ID: 9702221
you can use:

<%
  for (int i = 0; i < arr.length; i++) {
%>
<input type="hidden" name="darray" value="<%= arr[i] %>">
<%
  }
%>

and then get it in another page like this:
String[] myarray = request.getParameterValues("darray");
0
 
LVL 3

Expert Comment

by:applekanna
ID: 9703464
>>>Target page
-----------------
<%
String[] arr = session.getAttribute("arr");
%>

Just a clarification..
Dont we need to do a type cast ?How do you type cast a String arrary?
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9703504
Sorry yes.

String[] arr = (String[])session.getAttribute("arr");
0
 

Author Comment

by:tizay
ID: 9712262
thanks a lot mrishmawy
0
 

Expert Comment

by:paragagarwal
ID: 9712401
Simply keeep this array in Session and then retrieve it in other page
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

If you’re involved with your company’s wide area network (WAN), you’ve probably heard about SD-WANs. They’re the “boy wonder” of networking, ostensibly allowing companies to replace expensive MPLS lines with low-cost Internet access. But, are they …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 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