The Artima Developer Community
Sponsored Link

Java Answers Forum
How to post array of objects

2 replies on 1 page. Most recent reply: Oct 5, 2006 11:27 PM by surekha mitnala

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
surekha mitnala

Posts: 6
Nickname: pulipaka
Registered: Oct, 2006

How to post array of objects Posted: Oct 5, 2006 2:05 AM
Reply to this message Reply
Advertisement
Hi All,

I am a beginner in Java. I have done a program where I am supposed to send an array of beans to the JSP to display. Someone please help me. I am placing my code here..
At the end of the code I am placing a function which actually posts my array of beans. But I am facing a null pointer Exception.

public int exampleFunction()throws Exception{

String sourceversion = "";
String targetversion = "";

DBdataMigration migration = new DBdataMigration();


ArrayList records = new ArrayList();
ArrayList Record = new ArrayList();
int i=0; ResultSet r = migration.getListOfTargetVersions();

migrationbean = new HrMigrationStatusDataBean[2];

while (r.next()){
try{ sourceversion = r.getString(1); targetversion = r.getString(2);
records = migration.ReturnDBMigrationRows(targetversion); migrationbean.setSourceVersion(sourceversion); migrationbean.setTargetVersion(targetversion); migrationbean.setPercentMigrated(records.get(0).toString()); migrationbean.setMigrateStatus(records.get(1).toString()); migrationbean.setDateCompleted(records.get(2).toString()); }
catch(Exception ex){
log("values are : " + sourceversion);
log("values are : " + targetversion);
}
i++;
}//end of while
int count1 = i;
return count1;
}

public HrMigrationStatusDataBean[] getinfo(){// parasoft-suppress JAVADOC.PJDM

return migrationbean;
}


Dave Hinton

Posts: 42
Nickname: catbells
Registered: Oct, 2003

Re: How to post array of objects Posted: Oct 5, 2006 6:42 AM
Reply to this message Reply
Which line of code throws the exception?

Repost your source code inside [ java] [/ java] tags. Because you didn't, it's difficult to read, and some of it has been removed and the web site thinks some of it is a control code for italics. So we can't be sure what actually appears in your program.

surekha mitnala

Posts: 6
Nickname: pulipaka
Registered: Oct, 2006

Re: How to post array of objects Posted: Oct 5, 2006 11:27 PM
Reply to this message Reply
In the code, while I am returing the migrationbean, it is throwing a null value. I am not sure whether the values are actually getting into the bean or not.I have given some logs in the getInfo function to trace, but no use.

public HrMigrationStatusDataBean[] getinfo(){// parasoft-suppress JAVADOC.PJDM
beans.setElementList(migrationbean);
HrMigrationStatusDataBean[] bean = beans.getElementList();
for (int k=0; k<2; k++){
log("The value of beans is" + bean);
}
String[][] values = null;
values = new String[2][6];
for (int j=0; j<2; j++){
values[j][0] = bean[j].getSourceVersion();
log("value is as follows" + values[j][0]);
values[j][1] = bean[j].getTargetVersion();
log("value is as follows" + values[j][1]);
values[j][2] = bean[j].getPercentMigrated();
log("value is as follows" + values[j][2]);
values[j][3] = bean[j].getMigrateStatus();
log("value is as follows" + values[j][3]);
values[j][4] = bean[j].getDateCompleted();
log("value is as follows" + values[j][4]);
}
return migrationbean;
}

Flat View: This topic has 2 replies on 1 page
Topic: EJB & J2EE interview questions Previous Topic   Next Topic Topic: Reading an array of strings

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use