Use application to display the page visits

Implemented in the jsp page.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head> 
< Body > 
        < h1 of > Hello </ h1 of > 
        <% -   
            shows the number of page views obtained 
            1 . Gets a null object in application NUM
             2 determines if NUM. ==  null on the note is the first visit provided equal num. 1
             . 3 .else the target object forcibly fitted into num int   type allowed to self-energizing
             4 . O access times obtained by the value of the num getAttribute file application  
             . 5 . console output and the page output in two ways. 
            
        - %>         
        <% 
            Object COUNT = application.getAttribute ( " NUM ");
             IF (COUNT == null ) { 
                application.setAttribute ( " NUM " , . 1 ); 
                
            } the else {
                 int A = ( int ) (COUNT); 
                A ++ ; 
                application.setAttribute ( " NUM " , A); 
            } 
             System.out.println ( " number of times of the output page is present: " + application.getAttribute ( " NUM " ));
        %> 
        Number of output pages are present: 
        <% = application.getAttribute ( " NUM " ) %> 
        
</ body > 
</ HTML >

 

Guess you like

Origin www.cnblogs.com/ZXF6/p/11086983.html