SQL Tag Out Examples : Database « JSTL « Java






SQL Tag Out Examples

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>

<sql:setDataSource var="dataSource" driver="sun.jdbc.odbc.JdbcOdbcDriver" url="jdbc:odbc:forum"/>

<html>
  <head>
    <title>SQL Tag Out Examples</title>
  </head>

  <body>

<sql:query var = "users" dataSource="${dataSource}">
select column_uid,column_pwd,column_accesses,column_first,column_last,column_bad,column_posted,column_type from t_users
</sql:query>

<table border=1>
<c:forEach var="row" items="${users.rows}">
<tr>
<td><c:out value="${row.column_uid}"/></td>
<td><c:out value="${row.column_pwd}"/></td>
<td><c:out value="${row.column_accesses}"/></td>
<td><c:out value="${row.column_first}"/></td>
<td><c:out value="${row.column_last}"/></td>
<td><c:out value="${row.column_bad}"/></td>
<td><c:out value="${row.column_posted}"/></td>
<td><c:out value="${row.column_type}"/></td>
</tr>
</c:forEach>
</table>


  </body>
</html>



           
       








JSTL-Data-Table-Access.zip( 6,553 k)

Related examples in the same category

1.JSTL SQL Query
2.JSTL SQL Update
3.Updating a database using the sql:update tag
4.Presenting database content using tags
5.JSTL: Transaction with a JSP