It mainly records the access times and total access times of a single page.
/// // Index. jsp /////////////////////////////////
Home Page
<Body>
<A href = "1.jsp"> 1 </a>
<%
Integer count = (Integer) application. getAttribute ("count ");
If (count = null ){
Count = 0;
}
%>
<A href = "2.jsp"> 2 </a>
<%
Integer count1 = (Integer) application. getAttribute ("count1 ");
If (count1 = null ){
Count1 = 0;
}
%>
Total visits:
<% = Count + count1 %>
</Body>
/// // 1.jsp ///// /////////////////////////////
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" %>
<%
Integer count = (Integer) application. getAttribute ("count ");
If (count = null ){
Count = 1;
Application. setAttribute ("count", count );
} Else {
Count ++;
Application. setAttribute ("count", count );
}
%>
The number of visitors is:
<% = Count %>
<A href = "index. jsp"> back to homepage </a>
/// // 2.jsp ///// //////////////////////////////////
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" %>
<%
Integer count1 = (Integer) application. getAttribute ("count1 ");
If (count1 = null ){
Count1 = 1;
Application. setAttribute ("count1", count1 );
} Else {
Count1 ++;
Application. setAttribute ("count1", count1 );
}
%>
The number of visitors is:
<% = Count1 %>
<A href = "index. jsp"> back to homepage </a>
Chenglong0513