This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Struts and the fly likes Iterate through a ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Iterate through a ResultSet" Watch "Iterate through a ResultSet" New topic

Iterate through a ResultSet

Ed Chawlik

Joined: Aug 10, 2005
Posts: 16
I am fairly new to struts and am trying to interate though an Oracle result set; the SCOTT/TIGER emp table. I saw this on another forum, but cannot get it to work. If someone knows of a better way or how to get this to work, I am all ears:

Regards, ed

Java Action code (works fine)

stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT EMPNO, ENAME FROM scott.emp");
rsdc = new RowSetDynaClass(rset);
request.setAttribute("customers", rsdc);

JASP code:

<logic:iterate id="customer" name="customers" property="rows" scope="request">
<br>This is filler text
<bean:write name="customer" property="EMPNO"/>  
<bean:write name="customer" property="ENAME"/>
</logic:iterate >


javax.servlet.ServletException: No getter method for property EMPNO of bean customer
Ergin Er
Ranch Hand

Joined: Sep 06, 2005
Posts: 60
Maybe you should convert the ResultSet to a List before you put it into session?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The trouble with this code is that your variable "customer" is of type DynaBean, and DynaBean is not a true javaBean. There is no getEMPNO() method but only a get(String) method. My suggestion would be to create an Employee bean. You could then create a list of Employee beans and use the BeanUtils.copyProperties() method to copy the properties of the DynaBean to the Employee bean.

Consultant, Sima Solutions
Ed Chawlik

Joined: Aug 10, 2005
Posts: 16
Thank you guys, I will give that a try.
I agree. Here's the link:
subject: Iterate through a ResultSet
jQuery in Action, 3rd edition