<%@ 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" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Statistics website Number of visitors and their current number of online </title>
<body>
<%! Integer yournumber=new integer (0); %>
<% if (session.isnew ()) {//If it is a new session
Integer number= (integer) application.getattribute ("Count");
if (number = = NULL)//If it is the 1th access site
{Number = new Integer (1);}
Else
{Number = new Integer (Number.intvalue () +1);}
Application.setattribute ("Count", number);
Yournumber = (Integer) application.getattribute ("Count");
}
%>
Welcome to visit this site, you are the first <%=yourNumber%> access users.
</body>
Run
Run in Browser again
Java Web ch03_14_applicatin.jsp