加油!继续学习!!!
application对象类似于“全局变量”,主要用在数据共享上,且只有一个实例。
常用方法:setAttribute(String key,Object value)保存对象
getAttribue(String key)通过key获得值
getRealPath(String path) 返回相对路径的真实路径。
application可以用来统计访问量。
<%
Integer count=(Integer)application.getAttribute("count");
if(count!=null){
count=count+1;
}else{
count=1
}
application.setAttribute("count",count);
%>
<Integer i=(Integer)application.getAttribute("count");
out.print("目前共有访问量:"+i);
%>