网站访问量统计案例

ServletContext application=this.getServletContext();
Integer count=(Integer) application.getAttribute("count");
if(count==null){
application.setAttribute("count", 1);
}else{
application.setAttribute("count", count+1);
}
response.setContentType("text/html;charset=utf-8");
//像浏览器输出
response.getWriter().write("该页面工访问"+count+""+"次");

posted @ 2017-03-31 19:39  贱贱的小帅哥  阅读(124)  评论(0编辑  收藏  举报