application
用于保存整个webapplication的生命周期内都可以访问的数据
在API中表现为servletcontext
通过httpservlet的getservletcontext方法可以拿到
通过servletcontext的get/setAttribute方法取得/设置相关属性
response.setContentType("text/html;charset=gb2312"); PrintWriter out = response.getWriter(); Integer accessCount =(Integer) application.getAttribute("accessCount"); if(accessCount == null){ accessCount = new Integer(0); }else{ accessCount = new Integer(accessCount.intValue() + 1); } application.setAttribute("accessCount,accessCount");