The first entry to JSP has already been mentioned in the BASIC script. In this article, let's talk about nine objects in JSP.
Out
The out Built-in object is a buffered output stream that is used to return information to the client. It is an instance of javax. servlet. jsp. jspwriter. In servlet, when writing information to the client, the getwriter method obtains the printwrtier object, and the printwriter and jspwriter have the same parent class-java. Io. Writer.
Used to return data to the client.
Request
The built-in request object indicates the request to call the JSP page. Generally, the request object is an instance of the javax. servlet. http. httpservletrequest interface.
A typical application of this object is to obtain parameters submitted by the client, but not only. It can also obtain other client information (such as IP address, header information, and path information ).
Note that the request can only obtain the data submitted this time.
Response
The response built-in object indicates the response returned to the client. Normally, the response object is an instance of the javax. servlet. http. httpservletresponse interface.
Typical applications of this object include setting the HTTP title, adding cookies, setting the content type and status, and sending HTTP redirection.
Note that response is only valid in this response.
Pagecontext
The built-in pagecontext object is an instance of javax. servlet. jsp. pagecontext, which represents the JSP page context.
Application of this object: Get the objects in the JSP page, such as request, response, and servletcontext, which can be obtained through pagecontext.
Note: This object is rarely used, because most of the objects that can be obtained by this object are encapsulated as built-in objects or can be directly obtained.
This object is only valid on this page.
Session
The session is valid for one session: the session generally starts from the first time the client connects to the server, to the Session Timeout (as stated in the configuration file ).
Note that the session has not been released yet after the client opens the browser and closes the browser. You can call an API that releases a session.
Application
Is an instance of servletcontex. The information stored is shared by all users.
When a web application is started, this built-in object is created. This object is shared by the entire web application. This object does not need to be said. Pay attention to the Declaration cycle.
Config
Is an instance of servletconfig, indicating the servlet configuration.
Exception
Exception is an instance of Java. Lang. throwable. An exception object is an exception object. This object is generated when a page encounters an exception during running. If the JSP page uses this object, you must set iserrorpage to true; otherwise, compilation fails.
Page
The page object is an instance of the current JSP page converted into a servlet class. Page objects are rarely used.
Finally, compare page and pagecontext:
Page, only the JSP page is converted to the servlet instance, and pagecontext refers to the context of the JSP page. However, there is very little difference between the two.