Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing values from ActionClass to jsp struts 1.1

 
Himanshu Rawat
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • 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
 
balakrishna billa
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
i did it...but i m nt able to retrieve in jsp..

can u give me sample code...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic