You can use the Xephryus Data Structures Taglib here, rather than dropping down into Java.
http://www.xephyrus.com/taglib-datastructs/ I've been very happily using it on a simple JSP-only system [well, JSP-only and JavaBeans because JSTL cannot treat Maps as beans *grumblegrumble*]. If interested, I can send the example code of taking sql into lists next week [code is at work]. Hen On Sat, 4 Oct 2003, Serge Knystautas wrote: > Why do you need it as an ArrayList? Generally it's bad practice to > reference objects by interface, not implementation. But anyway, to get > to List... > > <c:set var="rows" value="${rs.rows}" /> > <% > Object[] rows = (Object[]) pageContext.findAttribute("rows"); > List testList = Arrays.asList(rows); > %> > > -- > Serge Knystautas > President > Lokitech >>> software . strategy . design >> http://www.lokitech.com > p. 301.656.5501 > e. [EMAIL PROTECTED] > > [EMAIL PROTECTED] wrote: > > HI all, > > I am trying to figure out how to go from <sql:query var="rs" > > scope="page" dataSource="${conn}"> ... to an ArrayList that I need to > > feed to another taglib. I've looked through the Hans' JavaServer > > Pages book and found something that looked like it should work: > > > > <% > > ArrayList testList = new ArrayList(); > > %> > > > > <c:forEach items="${rs.rows}" var="row" varStatus="status"> > > <c:set var="partNum" value="${row.PartNumber}"/> > > <% > > String partNumber = (String) pageContext.getAttribute("partNum"); > > testList.add( partNumber ); > > %> > > </c:forEach> > > > > <% > > request.setAttribute( "testList", testList ); > > %> > > > > <display:table name="testList" class="its"/> > > > > However, the page is truncated before it even appears to run this > > code (last line is "<td>00008")? If I delete the scriptlet in the > > middle of the forEach loop the page displays properly with display > > tag saying that it is empty... I also tried using: > > > > <jsp:useBean id="partNum" class="java.lang.String"/> > > <% > > testList.add( partNum ); > > %> > > > > and got the same weird truncation. > > > > I'd appreciate some help on going from the sql tag's row collection > > to an ArrayList. > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
