http://www.alixixi.com/Dev/Web/JSP/jsp7/2007/2007020914328.html
servletContext application=getServletContext();
后面的一段函数是env.java的片断,可以看看在servlet中如何使用application变量的。
Integer count = null;
synchronized (application) {
count = (Integer) application.getAttribute("change");
if (count == null)
count = new Integer(0);
count = new Integer(count.intValue() + 1);
application.setAttribute("change", count);
}
servletContext application=getServletContext();
后面的一段函数是env.java的片断,可以看看在servlet中如何使用application变量的。
Integer count = null;
synchronized (application) {
count = (Integer) application.getAttribute("change");
if (count == null)
count = new Integer(0);
count = new Integer(count.intValue() + 1);
application.setAttribute("change", count);
}