This is a generic way to select data from a table and show the results in an HTML table using JSP taglibs. What is the generic way to do this in Grails? That is, take a few lines of SQL and generate an HTML table from scratch in Grails, including the column names as headers.
<sql:query var="results" dataSource="${dsource}">
select * from foo
</sql:query>
(# of rows: ${results.rowCount})
<table border="1">
<!-- column headers -->
<tr bgcolor=cyan>
<c:forEach var="columnName" items="${results.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>
</tr>
<!-- column data -->
<c:forEach var="row" items="${results.rowsByIndex}">
<tr>
<c:forEach var="column" items="${row}">
<td><c:out value="${column}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>