JSTL: Transaction with a JSP : Database « JSTL « Java






JSTL: Transaction with a JSP

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
<html>
<HEAD>
      <TITLE>Using a Transaction with a JSP</TITLE>
     </HEAD>
<body bgcolor="white">
          <h2>View table Data</h2>
  
<sql:transaction>  
    
  <sql:update>
  insert into atable values(2, 'Joe','Id','Feb-24-1996','F')
  </sql:update>
  
    <sql:query var="resultObj">
    select * from atable
    </sql:query>

</sql:transaction>  
<table>
<c:forEach items="${resultObj.rows}" var="row">
  <c:forEach items="${row}" var="column">
    <tr>
   <td align="right">
     <b><c:out value="${column.key}" /></b>
     </td>
     <td>
       <c:out value="${column.value}" />
     </td></tr>
     </c:forEach>
       </c:forEach>
     </table>
</body>
</html>



           
       








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.SQL Tag Out Examples