Solved

passing an array and retrieving that array

Posted on 2003-11-06
9
559 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 20 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

This article is in regards to the Cisco QSFP-4SFP10G-CU1M cables, which are designed to uplink/downlink 40GB ports to 10GB SFP ports. I recently experienced this and found very little configuration documentation on how these are supposed to be confi…
Choosing a core focus or particular set of features and options can be tough. To help out, we’re going to highlight a handful of things your business needs on one of your social media pages. In other words, if one of these is missing, you should imp…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 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