wood burning stoves 2.0*
The moose likes JSP and the fly likes problem while retrieving 2d array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem while retrieving 2d array" Watch "problem while retrieving 2d array" New topic
Author

problem while retrieving 2d array

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
i had 3 rows and 3 cols in the UI forum ;
i am creating 2 dimensional array in jsp and assigning requests to 2D array and after that storing into session object;

when i retrive the session object i am getting only last value of the 2D ARRAY thats is [3,3] value;

what wrong did i made in the below code

String formData[][] = null ;


for(int i=1;i<4;i++)
{
for(int j=1;j<4;j++)
{

if(request.getParameter("mytextbox"+i+j+"_"+pageNumber) != null && !"".equals(request.getParameter("mytextbox"+i+j+"_"+pageNumber)))
{
formData =new String[4][4];
formData[i][j] = request.getParameter("mytextbox"+i+j+"_"+pageNumber);
}

}
}
session.setAttribute("myFormDataForPage"+pageNumber, formData);


if(session.getAttribute("myFormDataForPage"+pageNumber) != null && !"".equals(session.getAttribute("myFormDataForPage"+pageNumber)))
{

formData =(String[][])session.getAttribute("myFormDataForPage"+pageNumber);
for(int i=1;i<4;i++)
{
for(int j=1;j<4;j++)
{
System.out.println("session values in controllerrrrrrrrrrr="+formData[i][j]);
}
}
}
sanjeevmehra mehra
Ranch Hand

Joined: Aug 21, 2004
Posts: 75
formData =new String[4][4];

above statement is in for loop. a logical problem (error).

hope this would be helpful.

pls. use code tag for posting code. u would get more reply & much earlier. just a suggestion


thanks & regards,
sanjeev.


thanks & regards,<br />Sanjeev.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem while retrieving 2d array
 
Similar Threads
Session variable returns null value
saving the details in when i click next and previous buttons
ArrayList gets duplicate values in JSP
Disabling a submit button.
where this program goes wrong(using 2D array)?