Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Struts LinkedHashMap list request scope

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i have an issue in struts 1.3,  getting data from database in the form of key , value pair , key is an Integer and value is a customer object,  able to display using logic iterate tag,

ActionForm having setter and getters of type LinkedHashMap (Integer, customer)
Scope of actionform request

Problem is when I submit request  lossing LinkedHashMap object data,  how to retain data in  action form  
Posts: 9615
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 1.x is past end of life and is unsupported.  If it is at all possible, upgrade to the latest version of Struts 2 or another framework.
If you want to persist a collection to a JSP and recover it later, you have to use indexed properties.  If you aren't displaying the properties on the page, it may be easier to put the value in the session.
Chakravathy Rajan
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am trying similar to the example given in indexed properties. able to successfully retain data using indexed properties  if i keep data in list.
but for LinkedHashMap if i got any example its very help ful.

how to declare in form and  how to iterate in jsp.

my code in form written like below
private LinkedHashMap<Integer,Customer> simTypeMaPlist;

public LinkedHashMap<Integer, Customer> getSimTypeMaPlist() {
return simTypeMaPlist;
public void setSimTypeMaPlist(
LinkedHashMap<Integer, Customer> simTypeMaPlist) {
this.simTypeMaPlist = simTypeMaPlist;

public Customer getSimMapItem( int key ) {
       if (this.simTypeMaPlist == null) {
           this.simTypeMaPlist = new LinkedHashMap<Integer, Customer>();
       while (!(this.simTypeMaPlist.containsKey(key))) {
           this.simTypeMaPlist.put( key,new IndividualContact() );
       return (Customer) this.simTypeMaPlist.get( key );

<logic:iterate id="simItem1" name="SampleForm" property="simTypeMaPlist"  indexId="idx">
<html:hidden name="simItem1" property ="key" indexed="true"/>
<html:hidden name="simItem1" property ="value" indexed="true"/>
            <bean:write name="simItem1" property="value.firstName"/>
<bean:write name="simItem1" property="key"/>

please correct  , so that i can retain values when i form submit.

Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic