Login cookie achieve record time

<%@ page import="java.util.SimpleTimeZone" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/6/27
  Time: 8:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
  $END$
  <form action="#" method="post">
      <input type="text" name="admin" ><hr/>
      <input type="password" name="password" ><hr/>
      <input type="submit" value="LinkStart">
  </form>
    <%
        DATE DATE = new new DATE (); 
        the SimpleDateFormat SDF = new new the SimpleDateFormat ( " HH: mm: SS " );
         // get current system time 
        String nowtime = sdf.format (DATE); // this time to a String
         // setting a cookie, which is named lasttime, the value of the system time of type String 
        cookies C = new new cookies ( " lastTime " , nowtime);
         // Cookie add this to the response 
        response.addCookie (C);
         // the response of All cookie will fall out into a full array tm engage in a cookie named cs 
        cookies cs [] = request.getCookies ();
        Tag Boolean = to false ;
         // 
        // traverse the array cookie, which attention determination conditions 
        IF ( null = CS && cs.length>! 0 ) {
           for (C1 cookies: CS) {
               // Once lastTime called a cookie is found, the 
              IF (c1.getName () the equals (. " lastTime " )) { 
                  Tag = to true ;
                   // output of the last access time 
                  OUT .write ( " the time of our last visit is: " + c1.getValue ()) ;
                   BREAK 
          } ;
              }
        } 
        IF (! Tag) {
             OUT .write ( " You are the first visit to this site " ); 
        }

     %> 
  </ body> 
</ HTML>

 

Guess you like

Origin www.cnblogs.com/fanqiexin/p/11101982.html