application pageContext

来源:互联网 发布:plc编程入门 编辑:程序博客网 时间:2024/05/29 19:18

application(ServletContext) :作用范围整个服务器,只要服务器不关就不会消失   getServletContext();

page(pageContext):作用范围是当前页面
 
session:作为范围本次会话,也就是如果你不换或者关闭浏览器。
所以可以利用
application做网站访问统计<%!synchronized void countPeople(){   ServletContext application=getServletContext();   Integer number=(Integer)application.getAttribute("Count");   if(number==null){   number=new Integer(1);   application.setAttribute("Count",number);}else{   number=new Integer(number.intValue()+1);   application.setAttribute("Count",number);}} %>


原创粉丝点击