Presenting database content using tags : Database « JSTL « Java

Presenting database content using tags

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

<%@ taglib prefix="sql" uri="" %>
<%@ taglib prefix="c" uri="" %>
<title>Presenting database content using tags</title>

<h1>Address List</h1>
<sql:query dataSource="${conn}" var="addresses">
    SELECT * FROM AddressList
<table width="90%" border="1">
<!-- add the table column headings -->
<c:forEach var="columnName" items="${addresses.columnNames}">
  <th> <c:out value="${columnName}"/> </th>
<!-- add the table rows from the result set -->
<c:forEach var="row" items="${addresses.rowsByIndex}">
    <c:forEach var="column" items="${row}">
      <td><c:out value="${column}"/></td>


Related examples in the same category

1.JSTL SQL Query
2.JSTL SQL Update
3.Updating a database using the sql:update tag
4.JSTL: Transaction with a JSP
5.SQL Tag Out Examples