web统计访问量
来源:互联网 发布:福州地铁软件 编辑:程序博客网 时间:2024/05/01 14:48
1.链接访问网页(jsp)
2.servlet(方法)
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("接收到");
ServletContext context = getServletContext();
int count = 0;
synchronized (context) {
if(null == context.getAttribute("counter")){
count = 1;
}else{
count = Integer.parseInt((String) context.getAttribute("counter"));
count = count+1;
}
context.setAttribute("counter", count+"");
req.setAttribute("counter1", count+"");
}
System.out.println("准备发送,已经访问"+count+"次");
req.getRequestDispatcher("/newCounter.jsp").forward(req, resp);
}
throws ServletException, IOException {
System.out.println("接收到");
ServletContext context = getServletContext();
int count = 0;
synchronized (context) {
if(null == context.getAttribute("counter")){
count = 1;
}else{
count = Integer.parseInt((String) context.getAttribute("counter"));
count = count+1;
}
context.setAttribute("counter", count+"");
req.setAttribute("counter1", count+"");
}
System.out.println("准备发送,已经访问"+count+"次");
req.getRequestDispatcher("/newCounter.jsp").forward(req, resp);
}
3.配置web.xml
4.访问界面接受(jsp):
<%String conter = (String)pageContext.getServletContext().getAttribute("counter");%>
<%String conter1 = (String)request.getAttribute("counter1"); %>
第三个网页
0 0
- web统计访问量
- Java web----Servlet统计页面访问量
- 统计访问量
- 统计访问量
- 访问量统计
- 统计访问量
- 网站访问量统计实现.
- 统计日访问量(c#)
- dwr 统计网站访问量
- 网站访问量统计
- google 访问量统计
- JSP + Servlet统计访问量
- 网站访问量统计
- 统计网站访问量
- 网站访问量的统计
- 访问量统计:在线 & 总
- awk命令统计访问量
- dedecms 中 统计访问量
- Java中的Set,List,Map的区别
- DD命令
- 你应该首先保护哪些应用程序?这个问题本身问错了!
- c++ String普通构造函数,拷贝构造函数,赋值函数书写
- iOS:An error was encountered while running (Domain = FBSOpenApplicationErrorDomain, Code = 4)
- web统计访问量
- Kafka delivery保证(kafka消息投递保证)
- Android 自定义View (三) 圆环交替 等待效果
- ListView几个比较特别的属性
- ios-day11-02(控制器的多种创建方式。init方法创建、通过storyboard的创建、通过xib创建)
- 一步一步写算法(之hash表)
- DNS bind9配置
- python的Socketserver模块使用,异常处理
- Linux下DISPLAY环境变量的作用