统计访问次数的简易方法

public class Count
{
	private int count;

	public int getCount()
	{
		return ++count;
	}

	public void setCount(int count)
	{
		this.count = count;
	}
	
	

}

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>    
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>计数器</title>
</head>
<body>
  <jsp:useBean id="count" class="com.chinasoft.zy.Count" scope="session"></jsp:useBean>
  <jsp:useBean id="count2" class="com.chinasoft.zy.Count" scope="application"></jsp:useBean>

  您的访问次数:<jsp:getProperty name="count" property="count"/><br>
  
  总共的访问次数:<jsp:getProperty name="count2" property="count"/>


</body>
</html>

 

你可能感兴趣的:(方法)