Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
- <%@ page language="java" contentType="text/html; charset=UTF-8"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Insert title here</title>
- </head>
- <body>
- <form method="post">
- <input type="text" name="idZupanije"/>
- <input type="submit" value="Dohvati"/>
- </form>
- <br/>
- <c:catch var="exception">
- <c:if test="${param.idZupanije < 1 || param.idZupanije > 22}">
- <p>ID nije u dobrom rasponu!</p>
- </c:if>
- <c:if test="${param.idZupanije >= 1 && param.idZupanije <= 22}">
- <sql:setDataSource var="connection" driver="com.mysql.jdbc.Driver"
- url="jdbc:mysql://localhost:3306/wauj"
- user="root" password="mysql"/>
- <sql:query dataSource="${connection}" var="result">
- SELECT zupanije.idzupanije, zupanije.nazivzupanije, COUNT(*) AS broj FROM mjesta
- JOIN zupanije ON mjesta.idzupanije=zupanije.idzupanije
- WHERE zupanije.idzupanije=?
- <sql:param value="${param.idZupanije}"/>;
- </sql:query>
- <table border="1" style="text-align: center;">
- <tr>
- <th>ID županije</th>
- <th>Naziv županije</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:if>
- </c:catch>
- <c:if test="${exception != null}">
- <p>The exception is : ${exception}</p>
- </c:if>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement