application|js| Tutorial
Application of JSP tutorial--application
In the previous article we talked about using session in JSP to save private information for each user, but sometimes the server needs to manage parameters for the entire application so that each customer gets the same parameter value. What should you do in JSP? Like the session, the JSP uses the Application object, and the method of operation is the same as the session "Times New Roman".
Its APIs are used as follows:
Application. setattribute ("Item", Itemvalue); Set an Application variable
Integer i= (integer) application.getattribute ("ItemName"); Get//item
A simple example of the number of online statistics is given to illustrate the application of application (where leave is not considered), init.jsp (initialization), count.jsp (total number of statistics and output).
init.jsp
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<body bgcolor= "#FFFFFF" >
<%
Application.setattribute ("Counter", new Integer (0));
Out.println (Application.getattribute ("Counter"));
%>
</BODY>
</HTML>
count.jsp
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<body bgcolor= "#FFFFFF" >
<%
Integer i= (integer) Application.getattribute ("Counter");
I=new Integer (I.intvalue () +1);
Application.setattribute ("Counter", I);
Out.println ((Integer) Application.getattribute ("Counter"));
%>
</BODY>
</HTML>