aspose file tools*
The moose likes Struts and the fly likes passing values from ActionClass to jsp struts 1.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "passing values from ActionClass to jsp struts 1.1" Watch "passing values from ActionClass to jsp struts 1.1" New topic
Author

passing values from ActionClass to jsp struts 1.1

Himanshu Rawat
Ranch Hand

Joined: Nov 27, 2005
Posts: 141
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


rawat
SCJP 1.4
balakrishna billa
Greenhorn

Joined: Mar 13, 2006
Posts: 13
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


balakrishna
Himanshu Rawat
Ranch Hand

Joined: Nov 27, 2005
Posts: 141
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

Joined: Mar 13, 2006
Posts: 13
Set the List object in request scope by using request.setAttribute("xxxxx",list);

And get the same in the jsp.
Himanshu Rawat
Ranch Hand

Joined: Nov 27, 2005
Posts: 141
i did it...but i m nt able to retrieve in jsp..

can u give me sample code...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: passing values from ActionClass to jsp struts 1.1