Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : pocetak
- Created on : Apr 21, 2016, 12:03:09 PM
- Author : Admin
- --%>
- <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <sql:setDataSource var="snapshot" driver="org.h2.Driver"
- url="jdbc:h2:tcp://localhost/~/test"
- user="sa"
- password=""/>
- <form name="upis" method="POST">
- <input type="number" name="idZupanije"/>
- <input type="submit" value="Dohvati" />
- </form>
- <br>
- <c:choose>
- <c:when test="${(param.idZupanije < 1) || (param.idZupanije > 21)}">
- <br>
- Unesite broj između 1 i 21
- </c:when>
- <c:otherwise>
- <c:catch var="catchException">
- <sql:query dataSource="${snapshot}" var="result">
- select ZUPANIJE.IDZUPANIJE, ZUPANIJE.NAZIVZUPANIJE, count(MJESTA.IDZUPANIJE) AS "broj" from ZUPANIJE
- join MJESTA on ZUPANIJE.IDZUPANIJE = MJESTA.IDZUPANIJE
- where ZUPANIJE.IDZUPANIJE=?
- group by MJESTA.IDZUPANIJE
- <sql:param value="${param.idZupanije}"/>
- </sql:query>
- </c:catch>
- <c:choose>
- <c:when test="${catchException != null}">
- Exception: ${catchException} <br>
- Message: ${catchException.message}
- </c:when>
- <c:otherwise>
- <table border="1" width="50%">
- <tr>
- <th>Id</th>
- <th>Županija</th>
- <th>Broj mjesta u županiji</th>
- </tr>
- <c:forEach var="row" items="${result.rows}">
- <tr>
- <td><c:out value="${row.IDZUPANIJE}"/></td>
- <td><c:out value="${row.NAZIVZUPANIJE}"/></td>
- <td><c:out value="${row.broj}"/></td>
- </tr>
- </c:forEach>
- </table>
- </c:otherwise>
- </c:choose>
- </c:otherwise>
- </c:choose>
- <br />
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement