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