aspose file tools*
The moose likes Struts and the fly likes Retrieving List from DB and setting to JSP in struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Retrieving List from DB and setting to JSP in struts 2" Watch "Retrieving List from DB and setting to JSP in struts 2" New topic
Author

Retrieving List from DB and setting to JSP in struts 2

Mah Desh
Greenhorn

Joined: Aug 31, 2010
Posts: 2
Hi,

In JSP when I use

<%@ taglib prefix="s" uri="/struts-tags" %>
<s:iterator value="list">
<s:property /><br>
</s:iterator>

It prints output as
com.PPP.ebusiness.vo.ReportVO@b2fb1e
com.PPP.ebusiness.vo.ReportVO@8497f6

Here list is a ArrayList containing value objects of type ReportVO.
I want to print properties of ReportVO, how can I do it using it using iterator tag?

I need to declare somewhere that list returns ReportVO type and then retrieve property of that.

Thank you in advance.
Mah Desh
Greenhorn

Joined: Aug 31, 2010
Posts: 2
Its resolved. This worked

<s:iterator id="vo" value="list" status="com.ist.PPP.ebusiness.vo.ReportVO">
<s:property value="title"/><br>
..
..
</s:iterator>
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Actually the status attribute is not necessary. Its used when you want to know the iteration status like iteration number, even/odd etc. The problem was you were using s:property without specifying any attribute so the toString method of ReportVO was called thus printing the weird output...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving List from DB and setting to JSP in struts 2
 
Similar Threads
How to access a property attribute of a value outside of an iterate, but within another iterate
data lost from JSP back to same Action (struts 2)
Struts2 Save and Get updated List?
Sticky nested lists problem in Struts 2
How to iterate through List of objects using OGNL <s:iterator> tag in struts2