You could use the "forEach" tag from JSTL (http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html). "forEach" can iterate over ResultSet's (and RowSet's via inheritance) with the assistance from the helper class: javax.servlet.jsp.jstl.sql.ResultSupport . ResultSupport can convert ResultSet's to the JSTL friendly Result class.
-Chad Johnson ----- Original Message ----- From: "aps olute" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, July 17, 2002 6:19 PM Subject: CachedRowset with logic:iterate tag > How to iterate over a CachedRowSet using > <logic:iterate > tags? I have filled the CachedRowset > with a select > statement and am able to iterate using the > crs.getString(1) or the crs.getString(colname) > methods, > but no am ready to use Struts tags but dont know how. > Do I need to convert it a Collection type? but that > will eat up more memory as two copies CRS and the > Collection with same contents? > Is it necessary to use the Struts tags to work with > the rest of the Struts features? > > <?xml version="1.0"?> > <%@ page language="java" %> > <%@ page contentType="text/html" %> > <%@ page > import="sun.jdbc.rowset.CachedRowSet,javax.naming.InitialContext"%> > <jsp:useBean id="Contacts" > class="sun.jdbc.rowset.CachedRowSet" scope="session"> > <% InitialContext ctx = new InitialContext(); > javax.sql.DataSource ds = > (javax.sql.DataSource)ctx.lookup("java:/DefaultDS"); > java.sql.Connection con = ds.getConnection(); > Contacts.setCommand("SELECT name, > owner,species,sex,birth,death from pet"); > Contacts.execute(con); > Contacts.first(); %> </jsp:useBean> > <logic:present name="Contacts" property="name"> > <logic:iterate id="subs" name="Contacts" > type="sun.jdbc.rowset.CachedRowSet"> > <bean:write name="subs" property="name"/> > </logic:iterate> > </logic:present> > > > But nothing is ever printed. if i take out the > logic:present and logic:iterate and replaced with a > while (Contacts.next() Contacts.getString(1) at > least > i gets some output. > > > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Autos - Get free new car price quotes > http://autos.yahoo.com > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>