Advertisement
Guest User

Untitled

a guest
Apr 21st, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.74 KB | None | 0 0
  1. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  2. <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
  3. <%@ page language="java" contentType="text/html; charset=UTF-8"%>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8. <title>Insert title here</title>
  9. </head>
  10. <body>
  11.     <form method="post">
  12.         <input type="text" name="idZupanije"/>
  13.         <input type="submit" value="Dohvati"/>
  14.     </form>
  15.     <br/>
  16.     <c:catch var="exception">
  17.         <c:if test="${param.idZupanije < 1 || param.idZupanije > 22}">
  18.             <p>ID nije u dobrom rasponu!</p>
  19.         </c:if>
  20.         <c:if test="${param.idZupanije >= 1 && param.idZupanije <= 22}">
  21.             <sql:setDataSource var="connection" driver="com.mysql.jdbc.Driver"
  22.                 url="jdbc:mysql://localhost:3306/wauj"
  23.                 user="root" password="mysql"/>
  24.             <sql:query dataSource="${connection}" var="result">
  25.                 SELECT zupanije.idzupanije, zupanije.nazivzupanije, COUNT(*) AS broj FROM mjesta
  26.                 JOIN zupanije ON mjesta.idzupanije=zupanije.idzupanije
  27.                 WHERE zupanije.idzupanije=?
  28.                 <sql:param value="${param.idZupanije}"/>;
  29.             </sql:query>
  30.             <table border="1" style="text-align: center;">
  31.                 <tr>
  32.                     <th>ID županije</th>
  33.                     <th>Naziv županije</th>
  34.                     <th>Broj mjesta u županiji</th>
  35.                 </tr>
  36.                 <c:forEach var="row" items="${result.rows}">
  37.                     <tr>
  38.                         <td><c:out value="${row.idzupanije}"/></td>
  39.                         <td><c:out value="${row.nazivzupanije}"/></td>
  40.                         <td><c:out value="${row.broj}"/></td>
  41.                     </tr>
  42.                 </c:forEach>
  43.             </table>
  44.         </c:if>
  45.     </c:catch>
  46.     <c:if test="${exception != null}">
  47.         <p>The exception is : ${exception}</p>
  48.     </c:if>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement