session.setAttribute & getAttribute in while loop
843836Sep 14 2004 — edited Sep 15 2004I am trying to setAttribute in a loop. But I couldn't get any data (null) on the next page. Following are my scripts.
1st Page:
int m=0;
int g=0;
for (int x=1; x <= counter; x++) {
for (int y=1; y <= counter; y++) {
result[m] = x + "-" + y;
answer[m] = request.getParameter(result[m]);
m++;
}
}
while (g < total) {
session.setAttribute("answer[g]",answer[g]);
g++;
}
2nd Page:
int l=0;
while (l < total) {
result[l] = "answer[" + l + "]";
answer[l] = (String) session.getAttribute(result[l]);
l++;
}