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. Python标准库01正则表达式

    在学习网络爬虫的过程中,需要抓取网页的评论数,涉及到正则表达式,便顺便看了看.正则表达式是文字处理中常用的工具. 1正则表达式的常用字符串 .       任何单个字符 [] 字符集对单个字符给出取值 ...

  2. Database First/Code First

  3. Python列表以及列表的处理方法

    在Python中,当我们需要存储大量的数据时,可使用列表存储,列表本质是一种有序的集合 格式:列表名 = [列表元素1,列表元素2,列表元素3,...列表元素n] 如果想创建一个只有单个元素的列表,格 ...

  4. BluePrism初尝

    由于对工作的需求,现在开始接触了RPA. RPA是什么?第一次看见这个名词,我脑海里只有RPG的概念.一番查询,才知道是Robotic Process Automation的英文缩写,机器人流程自动化 ...

  5. Problem 7: 10001st prime

    By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. ...

  6. python的标准数据类型

    python有5种标准的数据类型 1. number(数字) int(有符号的整形) long(长整[也可以代表八进制和16进制]) float(浮点型) complex(复数类型) 2.string ...

  7. response导出Excel(一个新手的记录,可以时常查看,以免自己忘记)

    HttpResponse response = HttpContext.Current.Response;  response.ContentEncoding = System.Text.Encodi ...

  8. JavaScript||什么是面向对象

    什么是对象&面向对象 对象 是一个整体,对外提供功能.例:一个手机 电脑. 面向对象 使用的时候只关注提供的功能不关注内部的细节. 面向对象有三大特点: 抽象:将问题需求抽象出来 例:一个员工 ...

  9. mysql 自定义方法 function

    在创建函数的时候,如果报如下错误 这个时候一定要先执行:set global log_bin_trust_function_creators=TRUE; 第二步骤: delimiter ;;CREAT ...

  10. 网络协议中HTTP,TCP,UDP,Socket,WebSocket的优缺点/区别

    先说一下网络的层级:由下往上分为 物理层.数据链路层.网络层.传输层.会话层.表示层和应用层 1.TCP和UDP TCP:是面向连接的一种传输控制协议.属于传输层协议.TCP连接之后,客户端和服务器可 ...