Apologies if this is in one of the books on JSTL, I've only got Shawn's and it's not in there afaik.
It's a little JSTL snippet which dumps a database table to the screen. Such things in Java are easy enough to write, but I felt that one in JSTL would be educational [for myself]. Posting here just in case it's of use to anyone: [Call as: http://www.example.com/example/dumpTable.jsp?table=Users to dump the table named Users in the default dataSource ] <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %> <sql:query var="result"> SELECT * FROM <c:out value="${param.table}"/> </sql:query> <table border="1"> <tr> <c:forEach items="${result.columnNames}" var="hdr"> <th><c:out value="${hdr}"/></th> </c:forEach> </tr> <c:forEach items="${result.rowsByIndex}" var="row"> <tr> <c:forEach items="${row}" var="field"> <td><c:out value="${field}"/></td> </c:forEach> </tr> </c:forEach> </table> -- To unsubscribe, e-mail: <mailto:taglibs-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:taglibs-user-help@;jakarta.apache.org>
