Lab environment: Myeclipse10 + tomcat7
The Application object stores information for multiple applications. For each container, each user has an application object. After the server starts, an application object is automatically created, this object will be kept until the server is closed.
The following instances are used to count the page access times.
1. application. jsp
<% @ Page language = java import = java. util. * pageEncoding = UTF-8 %> <% int count = 0; String c_name = request. getParameter (c_name); try {count = Integer. parseInt (application. getAttribute (c_name ). toString ();} catch (Exception e) {} out. println (after the server is started, This page has been accessed + count + times); count ++; application. setAttribute (c_name, new Integer (count); %>
2. test_application.jsp
<%@ page language=java import=java.sql.* pageEncoding=utf-8 errorPage=%><%String path = request.getContextPath();String basePath = request.getScheme()+://+request.getServerName()+:+request.getServerPort()+path+/;%>
> Test counter
Resources: http://download.csdn.net/detail/svitter/7358563