JSP SQL značky a schéma.
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon Jan 25 17:44:00 2010 +0100 (2010-01-25)
changeset 195d93bf1c8093
parent 18 0deb8f6abcf5
child 20 2b441592f632
JSP SQL značky a schéma.
java/nekurak.net-web/web/WEB-INF/sun-web.xml
java/nekurak.net-web/web/WEB-INF/web.xml
java/nekurak.net-web/web/sql-znacky.jsp
sql/schéma.sql
     1.1 --- a/java/nekurak.net-web/web/WEB-INF/sun-web.xml	Sat Jan 16 02:43:45 2010 +0100
     1.2 +++ b/java/nekurak.net-web/web/WEB-INF/sun-web.xml	Mon Jan 25 17:44:00 2010 +0100
     1.3 @@ -1,12 +1,12 @@
     1.4  <?xml version="1.0" encoding="UTF-8"?>
     1.5  <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
     1.6  <sun-web-app error-url="">
     1.7 -    <context-root>/nekurak.net-web</context-root>
     1.8 -    <class-loader delegate="true"/>
     1.9 -    <parameter-encoding default-charset="UTF-8" />
    1.10 -    <jsp-config>
    1.11 -	<property name="keepgenerated" value="true">
    1.12 -	    <description>Keep a copy of the generated servlet class' java code.</description>
    1.13 -	</property>
    1.14 -    </jsp-config>
    1.15 +  <context-root>/nekurak.net-web</context-root>
    1.16 +  <class-loader delegate="true"/>
    1.17 +  <parameter-encoding default-charset="UTF-8"/>
    1.18 +  <jsp-config>
    1.19 +    <property name="keepgenerated" value="true">
    1.20 +      <description>Keep a copy of the generated servlet class' java code.</description>
    1.21 +    </property>
    1.22 +  </jsp-config>
    1.23  </sun-web-app>
     2.1 --- a/java/nekurak.net-web/web/WEB-INF/web.xml	Sat Jan 16 02:43:45 2010 +0100
     2.2 +++ b/java/nekurak.net-web/web/WEB-INF/web.xml	Mon Jan 25 17:44:00 2010 +0100
     2.3 @@ -23,4 +23,10 @@
     2.4  	<exception-type>java.lang.NullPointerException</exception-type>
     2.5  	<location>/WEB-INF/chyby/nullPointer.jsp</location>
     2.6      </error-page>
     2.7 +    <!-- Odkaz na DB spojení, které budeme používat -->
     2.8 +    <resource-ref>
     2.9 +	<res-ref-name>jdbc/nekurak</res-ref-name>
    2.10 +	<res-type>javax.sql.DataSource</res-type>
    2.11 +	<res-auth>Container</res-auth>
    2.12 +    </resource-ref>
    2.13  </web-app>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/java/nekurak.net-web/web/sql-znacky.jsp	Mon Jan 25 17:44:00 2010 +0100
     3.3 @@ -0,0 +1,46 @@
     3.4 +<?xml version="1.0" encoding="UTF-8"?>
     3.5 +<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
     3.6 +	  xmlns:sql="http://java.sun.com/jsp/jstl/sql"
     3.7 +	  xmlns:c="http://java.sun.com/jsp/jstl/core"
     3.8 +	  version="2.0">
     3.9 +    <jsp:directive.page contentType="application/xhtml+xml"/>
    3.10 +    <jsp:output doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    3.11 +		doctype-root-element="html"
    3.12 +		omit-xml-declaration="false"/>
    3.13 +
    3.14 +    <html xmlns="http://www.w3.org/1999/xhtml">
    3.15 +	<head>
    3.16 +	    <title>SQL značky</title>
    3.17 +	</head>
    3.18 +	<body>
    3.19 +	    <h1>SQL značky</h1>
    3.20 +
    3.21 +
    3.22 +	    <!-- nastavíme výchozí datový zdroj -->
    3.23 +	    <sql:setDataSource dataSource="jdbc/nekurak"/>
    3.24 +
    3.25 +	    <!-- Jednoduchý dotaz -->
    3.26 +	    <pre>SELECT * FROM podnik;</pre>
    3.27 +	    <sql:query var="podniky">SELECT * FROM podnik;</sql:query>
    3.28 +	    <ul>
    3.29 +		<c:forEach items="${podniky.rowsByIndex}" var="p">
    3.30 +		    <li><c:out value="${p[1]}"/></li>
    3.31 +		</c:forEach>
    3.32 +	    </ul>
    3.33 +
    3.34 +	    <!-- Parametrizovaný dotaz -->
    3.35 +	    <pre>SELECT * FROM podnik WHERE nazev = ?;</pre>
    3.36 +	    <sql:query var="podniky" sql="SELECT * FROM podnik WHERE nazev = ?;">
    3.37 +		<sql:param value="Na Kovárně"/>
    3.38 +	    </sql:query>
    3.39 +	    <ul>
    3.40 +		<c:forEach items="${podniky.rowsByIndex}" var="p">
    3.41 +		    <li><c:out value="${p[1]}"/></li>
    3.42 +		</c:forEach>
    3.43 +	    </ul>
    3.44 +
    3.45 +
    3.46 +	</body>
    3.47 +    </html>
    3.48 +
    3.49 +</jsp:root>
     4.1 --- a/sql/schéma.sql	Sat Jan 16 02:43:45 2010 +0100
     4.2 +++ b/sql/schéma.sql	Mon Jan 25 17:44:00 2010 +0100
     4.3 @@ -2,7 +2,7 @@
     4.4  -- PostgreSQL database dump
     4.5  --
     4.6  
     4.7 --- Started on 2010-01-16 02:43:00 CET
     4.8 +-- Started on 2010-01-25 17:42:09 CET
     4.9  
    4.10  SET statement_timeout = 0;
    4.11  SET client_encoding = 'UTF8';
    4.12 @@ -39,7 +39,7 @@
    4.13  ALTER TABLE nekurak.podnik_seq OWNER TO nekurak;
    4.14  
    4.15  --
    4.16 --- TOC entry 1847 (class 0 OID 0)
    4.17 +-- TOC entry 1848 (class 0 OID 0)
    4.18  -- Dependencies: 1568
    4.19  -- Name: podnik_seq; Type: SEQUENCE SET; Schema: nekurak; Owner: nekurak
    4.20  --
    4.21 @@ -89,7 +89,43 @@
    4.22      ADD CONSTRAINT podnik_pk PRIMARY KEY (id);
    4.23  
    4.24  
    4.25 --- Completed on 2010-01-16 02:43:01 CET
    4.26 +--
    4.27 +-- TOC entry 1847 (class 0 OID 0)
    4.28 +-- Dependencies: 10
    4.29 +-- Name: nekurak; Type: ACL; Schema: -; Owner: nekurak
    4.30 +--
    4.31 +
    4.32 +REVOKE ALL ON SCHEMA nekurak FROM PUBLIC;
    4.33 +REVOKE ALL ON SCHEMA nekurak FROM nekurak;
    4.34 +GRANT ALL ON SCHEMA nekurak TO nekurak;
    4.35 +GRANT USAGE ON SCHEMA nekurak TO nekurak_web;
    4.36 +
    4.37 +
    4.38 +--
    4.39 +-- TOC entry 1849 (class 0 OID 0)
    4.40 +-- Dependencies: 1568
    4.41 +-- Name: podnik_seq; Type: ACL; Schema: nekurak; Owner: nekurak
    4.42 +--
    4.43 +
    4.44 +REVOKE ALL ON SEQUENCE podnik_seq FROM PUBLIC;
    4.45 +REVOKE ALL ON SEQUENCE podnik_seq FROM nekurak;
    4.46 +GRANT ALL ON SEQUENCE podnik_seq TO nekurak;
    4.47 +GRANT USAGE ON SEQUENCE podnik_seq TO nekurak_web;
    4.48 +
    4.49 +
    4.50 +--
    4.51 +-- TOC entry 1850 (class 0 OID 0)
    4.52 +-- Dependencies: 1569
    4.53 +-- Name: podnik; Type: ACL; Schema: nekurak; Owner: nekurak
    4.54 +--
    4.55 +
    4.56 +REVOKE ALL ON TABLE podnik FROM PUBLIC;
    4.57 +REVOKE ALL ON TABLE podnik FROM nekurak;
    4.58 +GRANT ALL ON TABLE podnik TO nekurak;
    4.59 +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE podnik TO nekurak_web;
    4.60 +
    4.61 +
    4.62 +-- Completed on 2010-01-25 17:42:10 CET
    4.63  
    4.64  --
    4.65  -- PostgreSQL database dump complete