A summary of the knowledge points of application in JSP:
1. Once a Web application is started, a Application object is automatically created, and only one application object is shared throughout the application, that is, all customers accessing the site share a Application object.
2. Function: To save shared data during the whole application operation, to realize the sharing of data between users.
3.application Object life cycle: Starts from the Web server until the Web server shuts down.
The Application object is application-level, and if string name does not exist in application, the object obtained by method object GetAttribute (string name) is null.
The Application object can be manipulated anywhere under the same site, with two main operations, the following two methods:
Object GetAttribute (String name) extracts the specified object from the Application object.
void SetAttribute (String name,object value) adds an object to the Application object.
The basic introduction of this application:
through the application, to realize the shared message board function, as follows:
INPUTMESSAGE.JSP:
<%@ page language= "java" import= "java.text.*,java.util.*" contenttype= "text/html"; Charset=utf-8 "pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
checkmessage.jsp:
<%@ page language= "java" import= "java.text.*,java.util.*" contenttype= "text/html"; Charset=utf-8 "pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > showmessage.jsp:
<% @pageimport = "com.sun.org.apache.xml.internal.serializer.utils.StringToIntTable"%><%@ page language= " Java "import=" java.util.* "contenttype=" text/html; Charset=utf-8 "pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
Using application to realize the function of Sharing message board in JSP