struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Germuska <>
Subject Re: Newbie: pass ResultSet to JSP?
Date Fri, 21 Jun 2002 13:39:23 GMT
You can definitely use <logic:iterate> -- you just shouldn't try to 
iterate the ResultSet.  In a strict MVC/Model 2 approach, the 
ResultSet ("model") should be isolated from the JSP ("view").

In your action, just run through the result set and put the data 
values into a list of instances of some view-level adapter object. 
This lets your page work whether the data comes from a database, an 
XML file, or previously entered user data.

If you don't need anything sophisticated, your adapter could simply 
be a java.util.Map; if you think you're going to use these "views" of 
your data more often, you should make a simple bean.

Hope that helps.


At 6:25 AM -0700 2002/06/21, Struts Newsgroup ( wrote:
>Subject: Newbie: pass ResultSet to JSP?
>From: "David Chu" <>
>  ===
>I am trying to get my head around this struts framework for the first time.
>I am confused about the best/standard way to access data from a JSP.
>- Let's say I want a page list_items.jsp.
>- I have access to a bean that has a method that returns the results of a
>database query as a ResultSet object.
>- How should I iterate through the rows of the bean?
>- Complication: my jsp complains that the ResultSet object has been closed
>(because I closed the query)
>Is this the prefered encapsulator of data that I should be accessing through
>my JSP?  Hopefully I can use the <struts-logic:iterate> tag.
>Thanks for helping out a new struts developer!
>David C. Chu
>America Online
>Network Tools Intern
>To unsubscribe, e-mail:   <>
>For additional commands, e-mail: <>

* Joe Germuska    { }
"It's pitiful, sometimes, if they've got it bad. Their eyes get 
glazed, they go white, their hands tremble.... As I watch them I 
often feel that a dope peddler is a gentleman compared with the man 
who sells records."
	--Sam Goody, 1956
tune in posse radio: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message