The application| variable application variable is a valid global variable for a Web application and is useful for saving some globally valid values. Unlike session variables, application variables can be accessed using Application.getattribute () and Application.setattribute ().
In JSP, you can automatically reference the application variable, referring to the current Web application. (For Web applications, I'll discuss them in another place.) )
When referencing a application variable, you must use synchronization. Also, you need to test whether a application property already exists. Please study the following code, set a application property called "Change" below, and save an integer value. With respect to using application variables in a servlet, the method is consistent with the following code, however, you need to first describe a application as follows:
ServletContext Application=getservletcontext ();
The following function is a fragment of env.java that can be used to see how to use Application variables in a servlet.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service