java/nekurak.net-web/web/sql-znacky.jsp
changeset 19 5d93bf1c8093
child 21 ee0ff39a1bf5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/nekurak.net-web/web/sql-znacky.jsp	Mon Jan 25 17:44:00 2010 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
     1.6 +	  xmlns:sql="http://java.sun.com/jsp/jstl/sql"
     1.7 +	  xmlns:c="http://java.sun.com/jsp/jstl/core"
     1.8 +	  version="2.0">
     1.9 +    <jsp:directive.page contentType="application/xhtml+xml"/>
    1.10 +    <jsp:output doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    1.11 +		doctype-root-element="html"
    1.12 +		omit-xml-declaration="false"/>
    1.13 +
    1.14 +    <html xmlns="http://www.w3.org/1999/xhtml">
    1.15 +	<head>
    1.16 +	    <title>SQL značky</title>
    1.17 +	</head>
    1.18 +	<body>
    1.19 +	    <h1>SQL značky</h1>
    1.20 +
    1.21 +
    1.22 +	    <!-- nastavíme výchozí datový zdroj -->
    1.23 +	    <sql:setDataSource dataSource="jdbc/nekurak"/>
    1.24 +
    1.25 +	    <!-- Jednoduchý dotaz -->
    1.26 +	    <pre>SELECT * FROM podnik;</pre>
    1.27 +	    <sql:query var="podniky">SELECT * FROM podnik;</sql:query>
    1.28 +	    <ul>
    1.29 +		<c:forEach items="${podniky.rowsByIndex}" var="p">
    1.30 +		    <li><c:out value="${p[1]}"/></li>
    1.31 +		</c:forEach>
    1.32 +	    </ul>
    1.33 +
    1.34 +	    <!-- Parametrizovaný dotaz -->
    1.35 +	    <pre>SELECT * FROM podnik WHERE nazev = ?;</pre>
    1.36 +	    <sql:query var="podniky" sql="SELECT * FROM podnik WHERE nazev = ?;">
    1.37 +		<sql:param value="Na Kovárně"/>
    1.38 +	    </sql:query>
    1.39 +	    <ul>
    1.40 +		<c:forEach items="${podniky.rowsByIndex}" var="p">
    1.41 +		    <li><c:out value="${p[1]}"/></li>
    1.42 +		</c:forEach>
    1.43 +	    </ul>
    1.44 +
    1.45 +
    1.46 +	</body>
    1.47 +    </html>
    1.48 +
    1.49 +</jsp:root>