Cookie(页面访问次数)

来源:互联网 发布:windows live破解版 编辑:程序博客网 时间:2024/05/21 18:41

这篇文章所做的就是网页访问次数的统计刷新,以jsp的内置对象application为对象,进行代码编写,简简单单,希望看到的朋友多多指教!

<%@ 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"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>页面访问计数器</title></head><body><%   Object obj=application.getAttribute("counter");   if(obj==null){   application.setAttribute("counter",new Integer(1));   out.println("该页面被访问1次!<br />");   }else{   int counterValue=Integer.parseInt(obj.toString());   counterValue++;   out.println("该页面被访问"+counterValue+"次!<br />");   application.setAttribute("counter", counterValue);   }%></body></html>


原创粉丝点击