wood burning stoves 2.0*
The moose likes JSP and the fly likes Passing data from servlet to JSP to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing data from servlet to JSP to servlet" Watch "Passing data from servlet to JSP to servlet" New topic
Author

Passing data from servlet to JSP to servlet

Ron Rea
Greenhorn

Joined: Jul 03, 2001
Posts: 23
I am trying to pass an arraylist, created in a servlet, to the JSP (where its propertys are displayed and modified), then back to the servlet.
I am using this to pass the arraylist in the Action:
request.setAttribute(Constants.GRID_DETERMINATIONS_ARRAY_LIST, determinationsArray);
The JSP iterated through this and places its properties on the page:
<logic:iterate id="gridDeterminations"
name="<%=Constants.GRID_DETERMINATIONS_ARRAY_LIST %>"
scope="request"
type="com.coramhc.common.GridDeterminations">
But I cannot get this ArrayList back when I hit submit and execute a request.getAttribute within the Action. It comes back as null.
Any help would be GREATLY appreciated!!
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Putting objects in request scope means that they are only available for the lifetime of the request. In other words, from when the request comes in to the web server, until the response is sent back.
Judging by your question, it sounds as if the data is going to the user and then they are submitting another request. If you need to maintain state over multiple requests, you should consider using a wider scope such as session.
Hope that helps...
Simon
Ron Rea
Greenhorn

Joined: Jul 03, 2001
Posts: 23
Thanks very, very much for your reply!
I put the arraylist in session scope and now am able to pull it back in via a session.getAttribute.
One more question - although the JSP displays the arraylist properties, at which time I will make changes to a property and hit submit, when the action gets the arraylist (via the session.getAttribute) the changes are not there. Is there a step in the JSP that I am missing, like a setProperty, etc...
Thanks in advance!
example of JSP iterate:
<logic:iterate id="gridDeterminations"
name="<%= Constants.GRID_DETERMINATIONS_ARRAY_LIST %>"
scope="session"
type="com.coramhc.common.GridDeterminations">
<td><bean:write name="gridDeterminations" property="messageCode" filter="true"/> </td>
<td><bean:write name="gridDeterminations" property="messageDesc" filter="true"/> </td>
<td><bean:write name="gridDeterminations" property="messageSeverity" filter="true"/> </td>
<td>
<html:select property="processResp" size="1">
<htmlption value=""></htmlption>
<htmlption value="CMPLD">CMPLD</htmlption>
<htmlption value="OIS">OIS</htmlption>
<htmlption value="RDA">RDA</htmlption>
<htmlption value="BMA">BMA</htmlption>
<htmlption value="PMA">PMA</htmlption>
<htmlption value="DEN">DEN</htmlption>
</html:select>
</td>
<td>
<html:radio property="overrideInd" value="A"/>Approve
<html:radio property="overrideInd" value="D"/>Deny
</td>
<td> </td>
</font>
</tr>
</logic:iterate>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing data from servlet to JSP to servlet