An approach that I've used is to use the javax.servlet.jsp.jstl.sql ResultSupport and Result objects. I create a Result object from the ResultSet object in this line:
lResult = ResultSupport.toResult(lResultSet); I then pass the Result to the jsp: aRequest.setAttribute("departments", lResult); And display it using the jstl taqs as follows: <c:forEach var="department" begin="0" items="${departments.rows}"> <department> <name><c:out value="${department.name}"/></name> <description><c:out value="${department.description}"/></description> <phone><c:out value="${department.phone}"/></phone> <fax><c:out value="${department.fax}"/></fax> </department> </c:forEach> This allows me to close the Connection and keep the data alive (I think), so is this a good approach? Paul -----Original Message----- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED] Sent: 14 March 2003 11:16 To: Struts Users Mailing List Subject: Re: Data driven struts application On Fri, 14 Mar 2003, Robert McIntosh wrote: > Date: Fri, 14 Mar 2003 09:38:50 -0600 > From: Robert McIntosh <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: Re: Data driven struts application > > Using a ResultSet directly is generally seen as bad practice. > > At a minimum you should probably use the ResultSetDynaClass then next in > line would be a RowSetDynaClass, then JavaBeans. As for the JavaBean > properties question, it would be easier to return a Collection of > JavaBeans where each bean represented each row in the resultset. > Note that using ResultSetDynaClass doesn't get you out of leaving the underlying ResultSet open (and the connection allocated from your connection pool), so it is still not the best choice for making data available to the view tier. It's primary value is exposing ResultSet data as DynaBeans for processing inside the business tier. For maximum efficiency, no data copying is done -- it essentially synthesizes a DynaBean for the current row (have a look at the sources if you want to see the world's strangest "Iterator" implementation :-). RowSetDynaClass, on the other hand, is quite useful for making data available to the view tier. It makes a copy of the data, so the underlying result set can be immediately closed, and the connection returned to the connection pool. And, because it again exposes DynaBeans, all the standard Struts tags can deal with it just like a collection of standard JavaBeans. The only downside is that the copying can be computationaly and/or memory-wise expensive, so be sure you don't try things like performing a million row query and then trying to make a RowSetDynaClass out of it. > ~Robert Craig McClanahan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]