Advertisement
Yuvalxp8

Login + User Counter

Jan 23rd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5.     <head>
  6.         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7.         <link rel="stylesheet" type="text/css" href="cssForTopBar.css">
  8.         <title>Login</title>
  9.     </head>
  10.         <body>
  11.             <h2>Please Login: </h2>
  12.             <hr>
  13.                 <form id= "login" method="get" action="loginCheck.jsp">
  14.             <center>
  15.                 <table border="1" width="30%" cellpadding="3">
  16.                     <th>
  17.                         <tr>
  18.                             <th colspan="2">Login Here</th>
  19.                         </tr>
  20.                     </th>
  21.                     <tb>
  22.                         <tr>
  23.                             <td>User Name</td>
  24.                             <td><input type="text" name="uname" value="" /></td>
  25.                        </tr>
  26.                         <tr>
  27.                             <td>Password</td>
  28.                             <td><input type="password" name="pass" value="" /></td>
  29.                         </tr>
  30.                         <tr>
  31.                             <td><input type="submit" value="Login" /></td>
  32.                             <td><input type="reset" value="Reset" /></td>
  33.                         </tr>
  34.                     </tb>
  35.                 </table>
  36.             </center>
  37.                 </form>
  38.         <%
  39.                 session.setMaxInactiveInterval(2);
  40.             if(application.getAttribute("counter") == null || (Integer)application.getAttribute("counter") == 0)
  41.             {
  42.                 application.setAttribute("counter", 1);
  43.             }
  44.             if(session.isNew() == true)
  45.             {
  46.                 synchronized(page)
  47.                 {
  48.                     Integer counter = (Integer) application.getAttribute("counter");
  49.                     counter += 1;
  50.                     application.setAttribute("counter", counter);
  51.                 }
  52.             }
  53.         %>
  54.         <p><b>User Counter:</b> <%=application.getAttribute("counter")%></p>
  55.    
  56.    
  57.     </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement