java/nekurak.net-web/web/sql-znacky.jsp
author František Kučera <franta-hg@frantovo.cz>
Mon, 25 Jan 2010 17:44:00 +0100
changeset 19 5d93bf1c8093
child 21 ee0ff39a1bf5
permissions -rw-r--r--
JSP SQL značky a schéma.
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
     3 	  xmlns:sql="http://java.sun.com/jsp/jstl/sql"
     4 	  xmlns:c="http://java.sun.com/jsp/jstl/core"
     5 	  version="2.0">
     6     <jsp:directive.page contentType="application/xhtml+xml"/>
     7     <jsp:output doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
     8 		doctype-root-element="html"
     9 		omit-xml-declaration="false"/>
    10 
    11     <html xmlns="http://www.w3.org/1999/xhtml">
    12 	<head>
    13 	    <title>SQL značky</title>
    14 	</head>
    15 	<body>
    16 	    <h1>SQL značky</h1>
    17 
    18 
    19 	    <!-- nastavíme výchozí datový zdroj -->
    20 	    <sql:setDataSource dataSource="jdbc/nekurak"/>
    21 
    22 	    <!-- Jednoduchý dotaz -->
    23 	    <pre>SELECT * FROM podnik;</pre>
    24 	    <sql:query var="podniky">SELECT * FROM podnik;</sql:query>
    25 	    <ul>
    26 		<c:forEach items="${podniky.rowsByIndex}" var="p">
    27 		    <li><c:out value="${p[1]}"/></li>
    28 		</c:forEach>
    29 	    </ul>
    30 
    31 	    <!-- Parametrizovaný dotaz -->
    32 	    <pre>SELECT * FROM podnik WHERE nazev = ?;</pre>
    33 	    <sql:query var="podniky" sql="SELECT * FROM podnik WHERE nazev = ?;">
    34 		<sql:param value="Na Kovárně"/>
    35 	    </sql:query>
    36 	    <ul>
    37 		<c:forEach items="${podniky.rowsByIndex}" var="p">
    38 		    <li><c:out value="${p[1]}"/></li>
    39 		</c:forEach>
    40 	    </ul>
    41 
    42 
    43 	</body>
    44     </html>
    45 
    46 </jsp:root>