Application Object
what is application?
The Application object is generated when the server is started, and when the customer browses through the pages of the site visited, the application
objects are the same until the server shuts down. However, unlike the session, all clients ' application objects are the same, that is, all customers
Share this built -in The Application object.
Appliaction Object
The Application object wraps the object of the servlet's ServletContext class directly, and is an instance of the Javax.servlet.ServletContext class. This
Objects represent this JSP page throughout the entire life cycle of the JSP page. This object is created when the JSP page is initialized, with the Jspdestroy ()
is removed from the call of the method. By adding attributes to application, these properties are accessible to all JSP files that make up your web app.
The Application object can store information in the server until the server shuts down, otherwise the information stored in the Application object is applied throughout the
are valid in both. The Application object has a longer life cycle than the session object, similar to the system's global variables.
The Application object implements the sharing of data among users and can store global variables.
The Application object starts at the start of the server and terminates at the server's shutdown.
The same properties of the Application object can be manipulated in the connection between the user's back-and-forth connection or a different user.
Any manipulation of the properties of the Application object in any place will affect the access of other users to it.
The startup and shutdown of the server determines the life of the Application object.
Common methods for application objects:
Instance:
We create a new application.jsp page:
Operation Result:
Page Object
The Page object is an instance of the Java.lang.Object class. The Page object refers to the current JSP page itself, a bit like the this pointer in the class, the Page object
is a synonym for this object.
the object of the Page object is a reference to the pages instance. It can be seen as a representation of the entire JSP page. It is only legal within the JSP page.
Common methods for Page objects are:
Example:
page.jsp page:
Operation Result:
PageContext Object
The PageContext object is an instance of the Javax.servlet.jsp.PageContext class that represents the entire JSP page. PageContext objects are mainly
Used to access page information while filtering out most of the implementation details. This object stores a reference to the request object and the response object. Application
Objects, config objects, session objects, and out objects can be exported by accessing the properties of this object. The PageContext object also contains a pass to
JSP page instruction information, including cache information, ErrorPage URL, page scope and so on.
The purpose of the PageContext object is to obtain any range of parameters through which you can get the JSP page out, request, reponse,
Session, application and other objects. The creation and initialization of PageContext objects is done by the container, which can be used directly in the JSP page.
The PageContext object.
The PageContext object provides access to all objects and namespaces within a JSP page.
The PageContext object can be accessed to the session where this page is located, or it can take a property value from the application on which it resides.
The PageContext object is equivalent to the synthesizer of all the features in the page.
Common methods for PageContext objects:
Instance:
We use the session_page1.jsp page:
Then create a incldue.jsp page:
Finally, create the pagecontext.jsp page:
Open the session_page1.jsp page first:
Run the PageContext page again:
we can get both the user name and the current date.
Config Object
The Config object is an instance of the Javax.servlet.ServletConfig class that wraps the object of the servlet's ServletConfig class directly. Config object
Allows developers to access the initialization parameters of the servlet or JSP engine, such as file paths.
The Config object is used by the JSP engine to pass information to it when a servlet is initialized, including the parameters to be used when the servlet initializes
(consisting of parameter names and attribute values) and information about the server (by passing a ServletContext object).
The main purpose of the Config object is to obtain the server configuration information. The Getservletconfig () method of the Pageconext object can be used to obtain a
A config object. When a servlet initializes, the container passes some information through the Config object to the servlet. The developer can
The Web. xml file provides initialization parameters for servlet programs and JSP pages in the application environment.
Common methods for Config objects:
This requires us to learn more about the knowledge of the servlet.
Exception Object
The exception object is actually an instance of java.lang.Throwable. The exception object is an exception object that when a page is running
If an exception occurs, the object is created. If a JSP page is to be applied to this object, it must be set to true iserrorpage, otherwise it cannot be compiled.
The exception object wraps the exception information that was thrown from the previous page. It is often used to generate an appropriate response to an error condition.
The purpose of the exception object is to display exception information that can be used only on pages that contain iserrorpage= "true", in a generic JSP
Using this object in the page will not compile the JSP file. The Excepation object, like all objects in Java, has a system-provided inheritance structure.
The exception object almost defines all exception conditions. In a Java program, you can use the Try/catch keyword to handle exception conditions if the JSP page
exception that is not caught in the polygon, the exception object is generated and the The exception object is routed to the error page set in the page directive
In the error page, and then process the the exception object to be applied to.
Common methods for exception objects:
Example:
We create a new exception.jsp page:
Create a new exception1.jsp page that needs to output the exception information:
Operation Result:
JSP nine large built-in objects are commonly used:
Out, request, response, session, application
JSP nine large built-in objects are not commonly used:
Page, PageContext, exception, config
Java Web learning: JSP nine large built-in objects (iii)