Reply
Mon 2 Jul, 2012 12:42 am
i am getting null pointer exception when i am trying to migrate java 1.4 to 1.7. It was working when i was testing in 1.4. But when i was testing in 1.7 it was not working
below are the codes:
In jsp:
<td> <html:text property='<%= "duration[" + ind + "]" %>' styleClass="textfield" size="5" maxlength="5" />
</td>
In javabean:
public class CodeSpecialtyForm extends ValidatorForm {
private String codeType;
private String codeValue;
private String codeDesc;
private String codeSeq;
private String defunctInd;
private List durationList;
private List logbookTemplateList;
private String[] selectedSubtype;
private String durationForRetrospectivePosting;
private String shortName;
private List subtypeCodes;
private List templateOptions;
private String hepBInd;
private String[] useLogbook;
/* properties for training duration (years) */
public List getDurationList() {
return durationList;
}
public void setDurationList(List durationList) {
System.out.println("durationList===>**"+durationList);
this.durationList = durationList;
System.out.println("durationList**"+durationList);
}
public String getDuration(int index) {
// make sure list is not null
if (this.durationList == null) {
this.durationList = new ArrayList();
}
// indexes do not come in order, populate empty spots
while (index >= this.durationList.size()) {
this.durationList.add(new String());
}
// return the requested item
return (String) durationList.get(index);
}
public String setDuration(int index, String duration) {
// make sure list is not null
if (this.durationList == null) {
this.durationList = new ArrayList();
}
// indexes do not come in order, populate empty spots
while (index >= this.durationList.size()) {
this.durationList.add(new String());
}
// return the requested item
return (String) durationList.set(index, duration);
}
/* properties for logbook template */
In simplest terms, a null pointer problem means you've tried to use pointer to which no real space has been assigned.
@gungasnake,
NullPointerException is the exception that occurred when a programmer perform an operation on a object or calling a method on the object i.e null. This exception is thrown by JVM.We should not handle that exception by try and catch block