This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Struts LinkedHashMap list request scope  RSS feed

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: 9550
Linux Mac OS X 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.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!