This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
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 Soft Skills this week in the Jobs Discussion 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: 9317
    
  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