Guest User

Untitled

a guest
Jan 17th, 2016
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
  3.  
  4. <%--
  5. Document : index
  6. Created on : 2015-10-30, 18:23:32
  7. Author : kamil
  8. --%>
  9.  
  10. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  11.  
  12.  
  13. <!DOCTYPE html>
  14. <html>
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  17. <link rel="Stylesheet" type="text/css" href="style.css" />
  18. <link href="css/bootstrap.min.css" rel="stylesheet">
  19. <script src="js/bootstrap.min.js"></script>
  20. <script src="js/jquery-2.1.4.min.js"></script>
  21.  
  22. <title>JSP</title>
  23. </head>
  24. <body>
  25.  
  26. <% if(request.getParameter("wyl") != null) session.removeAttribute("wynik"); %>
  27.  
  28. <sql:setDataSource var="Polaczenie" driver="com.mysql.jdbc.Driver"
  29. url="jdbc:mysql://localhost/mydb"
  30. user="root" password=""/>
  31.  
  32. <div id="logowanie">
  33.  
  34. <form action="index.jsp" method="POST">
  35.  
  36. <input type="text" name="login" size="15" placeholder="Login" class="form-control"><br>
  37. <input type="password" name="haslo" size="15" placeholder="Hasło" class="form-control"><br>
  38. <input type="submit" value="Zaloguj" class="btn btn-default" >
  39.  
  40.  
  41.  
  42. <c:if test="${param.Login != null}">
  43.  
  44. <sql:query dataSource="${Polaczenie}" var="wynik" scope="session">
  45. SELECT idUzytkownicy, Login, Haslo, ID_uprawnien, ID_adresu from uzytkownicy where Login = ? and Haslo = ?;
  46. <sql:param value="${param.Login}"/>
  47. <sql:param value="${param.Haslo}"/>
  48.  
  49. </sql:query>
  50.  
  51. <c:choose>
  52. <c:when test="${wynik.getRowCount() > 0}">
  53. <% response.sendRedirect("menu.jsp"); %>
  54. </c:when>
  55. <c:otherwise>
  56. <div id="bladlogowania">Błędny login lub hasło !</div>
  57. <%session.removeAttribute("wynik"); %>
  58. </c:otherwise>
  59. </c:choose>
  60.  
  61. </c:if>
  62.  
  63. </form>
  64. </div>
  65.  
  66. </body>
  67. </html>
Add Comment
Please, Sign In to add comment