Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem in passing an Arraylist from JSP to action class

Status
Not open for further replies.

anonymous10

Programmer
Jul 2, 2005
1
GB
I am setting an attribute in my JSP and access the attribute in my action class. I end up getting a null pointer exception.

In my JSP I do

<%
request.setAttribute("messageList", aMsgList);
System.out.println("Before for loop. Size =" +aMsgList.size());
<li> <A href="inboxMsg.do?Id=<%=i%>"><%=aTaskId%><%=aTaskMsg%></A></li>
%>

My struts config is as follows
<action
path="/inboxMsg"
type="com.abcd.def.actions.InboxAction">
<forward name="success" path="/WEB-INF/jsp/inboxmessage.jsp"/>
<forward name="failure" path="/WEB-INF/jsp/failure.jsp"/>

</action>



In my action class I try to read my arraylist as follows

ArrayList MsgList = (ArrayList) request.getAttribute("messageList");
int anIndex=Integer.parseInt(request.getParameter("Id"));
System.out.println("Size of Message List=" + MsgList.size());


When the last line is executed I get a null pointer exception.

I would be grateful for any suggestions.
 
<%
request.setAttribute("messageList", aMsgList);
System.out.println("Before for loop. Size =" +aMsgList.size());
<li> <A href="inboxMsg.do?Id=<%=i%>"><%=aTaskId%><%=aTaskMsg%></A></li>
%>

Could you show us how you are defining aMsgList please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top