N
Nino
Hello,
I have a double array that I store in the session variable: finalList[]
[]
String[][] finalList = new String[8][25];
.... do some work to pull information into double array ...
session.setAttribute("array.fl", finalList);
All good so far. I can call the array from anywhere in my program
without having the pull the information and sort it again. Now, I am
building a piece that allows a user to edit the information, but if
they don't like the changes they can go back to how it was. Thus I
decided to build a new array with a similar structure to hold the
information temporarily. Once the final "Save" button has been
clicked, it will store the temporary array information into the
finalList... like this:
String[][] editFinalList = new String[8][25];
if (session.getAttribute("array.efl") == null) {
editFinalList = (String[][]) session.getAttribute("array.fl");
session.setAttribute("array.efl", editFinalList);
} else {
editFinalList = (String[][]) session.getAttribute("array.efl");
}
Here's the problem... Any changes I make to editFinalList are
automatically stored in the session variable for finalList!! I wrote
the following code (on a completely different Servlet) to see what was
in all my session variables:
String finalList[][] = (String[][]) session.getAttribute("array.fl");
for (int x=0; (x < finalList[0].length) && (finalList[0][x] != null); x
++) {
out.println(""+finalList[0][x]+" ... etc ... ");
}
Once I add the information to the editFinalList array, nowhere do I
make a reference to finalList. However, it still updates it and when I
run the above code, it shows that changes were made to the finalList
array. How is this possible? Is there something I'm missing or don't
understand completely? Should I try another approach to editing data
and storing it temporarily?
I'm pulling my hair out here and appreciate any help. Thanks,
Nino Skilj
I have a double array that I store in the session variable: finalList[]
[]
String[][] finalList = new String[8][25];
.... do some work to pull information into double array ...
session.setAttribute("array.fl", finalList);
All good so far. I can call the array from anywhere in my program
without having the pull the information and sort it again. Now, I am
building a piece that allows a user to edit the information, but if
they don't like the changes they can go back to how it was. Thus I
decided to build a new array with a similar structure to hold the
information temporarily. Once the final "Save" button has been
clicked, it will store the temporary array information into the
finalList... like this:
String[][] editFinalList = new String[8][25];
if (session.getAttribute("array.efl") == null) {
editFinalList = (String[][]) session.getAttribute("array.fl");
session.setAttribute("array.efl", editFinalList);
} else {
editFinalList = (String[][]) session.getAttribute("array.efl");
}
Here's the problem... Any changes I make to editFinalList are
automatically stored in the session variable for finalList!! I wrote
the following code (on a completely different Servlet) to see what was
in all my session variables:
String finalList[][] = (String[][]) session.getAttribute("array.fl");
for (int x=0; (x < finalList[0].length) && (finalList[0][x] != null); x
++) {
out.println(""+finalList[0][x]+" ... etc ... ");
}
Once I add the information to the editFinalList array, nowhere do I
make a reference to finalList. However, it still updates it and when I
run the above code, it shows that changes were made to the finalList
array. How is this possible? Is there something I'm missing or don't
understand completely? Should I try another approach to editing data
and storing it temporarily?
I'm pulling my hair out here and appreciate any help. Thanks,
Nino Skilj