tizay
asked on
passing an array and retrieving that array
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.
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
thanks in advance.
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!
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!
i need to know: are u inserting all the parameters into a db?
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" );
%>
Source page
-----------------
<%
session.setAttribute("arr"
%>
Target page
-----------------
<%
String[] arr = session.getAttribute("arr"
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>>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?
-----------------
<%
String[] arr = session.getAttribute("arr"
%>
Just a clarification..
Dont we need to do a type cast ?How do you type cast a String arrary?
Sorry yes.
String[] arr = (String[])session.getAttri bute("arr" );
String[] arr = (String[])session.getAttri
ASKER
thanks a lot mrishmawy
Simply keeep this array in Session and then retrieve it in other page
<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