You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Au-Yeung, Stella H" <st...@eds.com> on 2003/07/17 04:51:40 UTC
Request object Null Pointer
Hi:
I am getting a NULL pointer with the request object: Please see code below.
I got a NULL pointer trying to access "vehList' in the request object inside
the method "prepareListForUpdate". But I didn't get a NULL pointer
accessing "vehList" inside the method "setScheduleList".
So it looks like the 1st time it ran through the Action class, the request
object is ther. But the 2nd time it ran through the Action class, either
the request object is null or "vehList' is no longer in the request object.
===============================
Portion of Action class:
ArrayList vehList = new ArrayList();
==> initialize and set values for vehList here <====
if (formBean.isSearchAction()) // user clicks 'search' on form. Run
through this Action class the 1st time
{
request.setAttribute("vehList",vehList);
this.setScheduleList(request); // invoke another method
<=== eventually "first.jsp" with an 'Update" button is displayed
}
else if (formBean.isBlnUpdateAction()) // user clicks 'update' in
"first.jsp", Run through this Action class the 2nd time
{
this.prepareListForUpdate(request); // invoke another method
}
=============================
Portion of method "setScheduleList":
setScheduleList(javax.servlet.http.HttpServletRequest request)
{
// display vehList.size() AND IT PRINTED OUT OK
ArrayList l = (ArrayList) request.getAttribute("vehList");
EtLog.debug(this,"in setScheduleList, vehList,size()="+l.size());
}
==================================
Portion of method "prepareListForUpdate":
prepareListForUpdate(javax.servlet.http.HttpServletRequest request)
{
// display vehList.size() AND IT GAVE ME A NULL POINTER EXCEPTION
ArrayList l = (ArrayList) request.getAttribute("vehList");
EtLog.debug(this,"in prepareListForUpdate,
vehList,size()="+l.size());
}
====================================
Any help will be appreciated,
Newbie
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Request object Null Pointer
Posted by Andrew Hill <an...@gridnode.com>.
Well of course its null.
The second time through you arent calling
request.setAttribute("vehList",vehList) before calling
prepareListForUpdate()
-----Original Message-----
From: Au-Yeung, Stella H [mailto:stella.au-yeung@eds.com]
Sent: Thursday, 17 July 2003 10:52
To: 'struts-user@jakarta.apache.org'
Subject: Request object Null Pointer
Hi:
I am getting a NULL pointer with the request object: Please see code below.
I got a NULL pointer trying to access "vehList' in the request object inside
the method "prepareListForUpdate". But I didn't get a NULL pointer
accessing "vehList" inside the method "setScheduleList".
So it looks like the 1st time it ran through the Action class, the request
object is ther. But the 2nd time it ran through the Action class, either
the request object is null or "vehList' is no longer in the request object.
===============================
Portion of Action class:
ArrayList vehList = new ArrayList();
==> initialize and set values for vehList here <====
if (formBean.isSearchAction()) // user clicks 'search' on form. Run
through this Action class the 1st time
{
request.setAttribute("vehList",vehList);
this.setScheduleList(request); // invoke another method
<=== eventually "first.jsp" with an 'Update" button is displayed
}
else if (formBean.isBlnUpdateAction()) // user clicks 'update' in
"first.jsp", Run through this Action class the 2nd time
{
this.prepareListForUpdate(request); // invoke another method
}
=============================
Portion of method "setScheduleList":
setScheduleList(javax.servlet.http.HttpServletRequest request)
{
// display vehList.size() AND IT PRINTED OUT OK
ArrayList l = (ArrayList) request.getAttribute("vehList");
EtLog.debug(this,"in setScheduleList, vehList,size()="+l.size());
}
==================================
Portion of method "prepareListForUpdate":
prepareListForUpdate(javax.servlet.http.HttpServletRequest request)
{
// display vehList.size() AND IT GAVE ME A NULL POINTER EXCEPTION
ArrayList l = (ArrayList) request.getAttribute("vehList");
EtLog.debug(this,"in prepareListForUpdate,
vehList,size()="+l.size());
}
====================================
Any help will be appreciated,
Newbie
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org