//获取网页流量的统计
ServletContext context = getServletContext();
Integer count = null;
synchronized(context)
{
count = (Integer) context.getAttribute("counter");
if (null == count)
{
count = new Integer(1);
}
else
{
count = new Integer(count.intValue() + 1);
}
context.setAttribute("counter", count);
}
System.out.println("网页流量:"+count);
//tomcat重启以后,会被清空。