• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing data from servlet to JSP to servlet

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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">
<html:option value=""></html:option>
<html:option value="CMPLD">CMPLD</html:option>
<html:option value="OIS">OIS</html:option>
<html:option value="RDA">RDA</html:option>
<html:option value="BMA">BMA</html:option>
<html:option value="PMA">PMA</html:option>
<html:option value="DEN">DEN</html:option>
</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>
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic