Advertisement
Guest User

Untitled

a guest
Jan 24th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%--
  2.     Document   : Login
  3.     Created on : 2016-01-23, 15:47:50
  4.     Author     : Tomasz
  5. --%>
  6.  
  7. <%@page import="java.util.Random"%>
  8. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  9. <!DOCTYPE html>
  10. <html>
  11.     <head>
  12.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  13.         <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
  14.         <script type="text/javascript" src="CJS.js"></script>
  15.         <title>Login JSP Page</title>
  16.     </head>
  17.     <body>
  18.         <%
  19.             String username = new String ();
  20.             String pass = new String ();
  21.             String rewrite = new String ();
  22.             String error = new String ("Hello!");
  23.            // Create cookies for first and last names.      
  24.            Cookie user = new Cookie("user", request.getParameter("username"));
  25.                                   //request.getParameter("username"));
  26.            Cookie password = new Cookie("pass", request.getParameter("pass"));
  27.  
  28.            // Set expiry date after 24 Hrs for both the cookies.
  29.            user.setMaxAge(60*60*24*30);
  30.            password.setMaxAge(60*60*24*30);
  31.  
  32.            // Add both the cookies in the response header.
  33.            response.addCookie( user );
  34.            response.addCookie( password );
  35.            
  36.  
  37.            if (!request.getSession().isNew()) {
  38.                if(request.getSession().equals(rewrite)){
  39.                    error="Invalid captcha!";
  40.                 //request.getSession().setAttribute("random", rewrite);
  41.                }
  42.            
  43.            }
  44.         %>
  45.         <!--<form method="GET" action="index.jsp">-->
  46.         <form method="get">
  47.             <strong>Hello Tom!</strong><br/>
  48.             Username: <input type="text" id="username" name="username" value="<%=username%>"><br/>
  49.             Password: <input type="text" id="pass" name="pass" value="<%=pass%>"><br/>
  50.             <input type="submit" value="Save">
  51.             <!--obstawiam że tutaj trzeba dać cookies, żeby wywołać odpowiednią losową liczbę
  52.             Rewrite this: <input type="text" id="original" name="original" value=""><br/>
  53.                 -->
  54.         <!--</form> -->    
  55.             Rewrite Captcha: <input type="text" id="rewrite" name="rewrite" value="<%=rewrite%>"><br/>
  56.            
  57.            
  58.             <input type="reset" id = "reload" value="Reload captcha">
  59.             <input type="submit" id = "login" value="Login to servlet"><br/>
  60.            
  61.             <div><img id="picture" src ="generated.jpg"/></div>
  62.         </form>
  63.        
  64.     </body>
  65. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement