• 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 values from ActionClass to jsp struts 1.1

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
the problem is like this ppl...

I want to pass values from ActionClass to jsp. for instance i made a List array in ActionClass and extracted some values from database and stored in it.
Now i want to show values of this list in jsp using struts tags.

If anyone knows how to do it..plzz tell.

thanks
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Do one thing, write FormBean class with setter/getter for the ArrayList.

like this

FormBean{

ArrayList aa = new ArrayList();
//setter/getter for the same.
}

and simply set ArrayList values in the Action class.
like this

ActionClass{

execute(.......){

//Get the Data from the DB
ArrayList arrayList = new ArrayList();
for(rs.next())
arrayList.add("...");

//get the form Object and set ArrayList

FormBean fb=(FormBean)form;

fb.setArrayList(arrayList);
return mapping.finForword("success");

}
}


Then u display the ArraList Values in the jsp using iterate tag in logic taglib.

xxxx.jsp

<logic:iterate id="dipaly" name="logical FormBean(st.con.xml)" property="arrayList" type="String or type Of OBj that arrList contains">
<bean:write id="display"/>
</logic:iterate>

you will find good tutorials here
http://www.laliluna.de/struts-nested-iteration-tutorial.html
 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

thanx for reply. I suppose this one method bt cant we directly pass values from ActionClass to jsp(struts 1.1). Suppose in action class i do some calculation and store in list. and retrieve in jsp!!!

if there is another way plzzz tell..


nyways thanks for help..
 
balakrishna billa
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Set the List object in request scope by using request.setAttribute("xxxxx",list);

And get the same in the jsp.
 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i did it...but i m nt able to retrieve in jsp..

can u give me sample code...
 
What could go wrong in a swell place like "The Evil Eye"? Or with this 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