application

  作用域:

    只要web服务器不关闭就一直存在

统计页面的统计次数

  一个用户 多次刷新也统计

  多个用户访问

思路:

  需要一个变量 count 记录index.jsp访问次数

方法

   public void setAttribute(String name,Object obj);

  public Object getAttrbute(String name );

【统计页面】

<%
//实现访问次数的统计
//1、先获取applicationd的属性值
Object count =application.getAttribute("count");
if(count==null){
//2、用户第一次访问 application没有这个值,所以设置一个application
application.setAttribute("count",1);
}else{
//3、用户第二次以上访问,已经有了application这个值,所以需要再原基础上再叠加+1
Integer intCount = (Integer) count;
application.setAttribute("count",intCount+1);
}
//将值取出来
Integer icount=(Integer)application.getAttribute("count");
//打印
out.print("访问次数是:"+icount); %>

application————web的更多相关文章

  1. Java获取路径的方法分析详解(Application/Web)

    1.利用System.getProperty()函数获取当前路径: System.getProperty("user.dir");//user.dir用户当前的工作目录,输出:D: ...

  2. tornado.web.Application类配置及使用

    Application configuration classtornado.web.Application(handlers=None, default_host='', transforms=No ...

  3. ThreadLocal Memory Leak in Java web application - Tomcat

    ThreadLocal variables are infamous for creating memory leaks. A memory leak in Java is amount of mem ...

  4. How to run a (Tomcat)Java application server on a Azure virtual machine

    http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-java-run-tomcat-applicatio ...

  5. Best Practices for Speeding Up Your Web Site

    The Exceptional Performance team has identified a number of best practices for making web pages fast ...

  6. tornado框架源码分析---Application类之debug参数

    先贴上Application这个类的源码. class Application(httputil.HTTPServerConnectionDelegate): """A ...

  7. Analysis of Web.xml in Hello1 project

    一.web.xml文件介绍 The web.xml file contains several elements that are required for a Facelets applicatio ...

  8. web.py框架之高级应用

    二.高级应用 2.1 web.ctx 获取客户端信息,比如:来源页面.客户端浏览器类型等. web.ctx基于 threadeddict类,又被叫做 ThreadDict.这个类创建了一个类似字典(d ...

  9. [转载]Best Practices for Speeding Up Your Web Site

    原文:http://developer.yahoo.com/performance/rules.html 提升网站加载速度的一些优化技巧,大部分在前端层面. 不知道是多久以前写的,看起来有些已经过时了 ...

随机推荐

  1. react-redux-store

    store是联系state 和 reducer的部分 Store 有以下职责: 维持应用的 state: 提供 getState() 方法获取 state: 提供 dispatch(action) 方 ...

  2. mybatis支持jdk8等localdate类型

    大家知道,在实体Entity里面,可以使用java.sql.Date.java.sql.Timestamp.java.util.Date来映射到数据库的date.timestamp.datetime等 ...

  3. Python入门学习例子——从Hao123获取图片

    import urllib.requestimport re #获取html页面内容def getHtml(url): data=urllib.request.urlopen(url) pageCon ...

  4. angular.js 渲染

    angular.js 小常识   具体看代码,转载请备注来源. html结构 <%@ page language="java" contentType="text/ ...

  5. Bring up a Kafka-based Ordering Service

    Bring up a Kafka-based Ordering Service 这篇文章假设读者对怎样设置Kafka集群和ZooKeeper集合已经初步了解.这篇文章的目的是讲解部署一个基于Kafka ...

  6. jmeter测试计划元素执行顺序

    jmeter测试计划元素执行顺序 测试计划的元素是有序的,通过以下方式执行: 1–配置节点 2–前置处理器 3–定时器 4–取样器 5–后置处理器(只在有结果可用情况下执行) 6–断言(只在有结果可用 ...

  7. leetcode 415 两个字符串相加

    string addstring(string s1,string s2) { string ans=""; ; ,j=s2.length()-;i>=||j>=;i- ...

  8. 模块四-shutil模块

    shutil模块 高级的文件处理模块 主要是文件的处理,移动,压缩和解压缩 shutil模块的使用方法: shutil.copyfile()#拷贝文件 shutil.copy()#拷贝文件和权限 sh ...

  9. JS的call与apply的用法

    call与apply的第一个参数都是需要调用的函数对象,在函数体内这个参数就是this的值,剩余的参数是需要传递给函数的值,call与apply的不同就是call传的值可以是任意的,而apply传的剩 ...

  10. 监控网络带宽 使用speedtest-cli命令

    1.监控网络带宽 使用speedtest-cli命令 l 安装命令: yum install python-pip –y pip install speedtest-cli l 运行命令: speed ...