JSP nine large built-in objects: request, response, session, application, out, page, PageContext, config, exception

Source: Internet
Author: User

A total of 9 such objects are pre-defined in JSP: request, Response, session, application, out, PageContext, config, page, exception

1. Request Object

The Request object is an object of type Javax.servlet.httpServletRequest. This object represents the client's request information and is primarily used to accept data that is delivered to the server over the HTTP protocol. (including header information, System Information, request method, request parameters, etc.). The request object is scoped to the requested one time.

2. Response Object

Response represents the response to the client, primarily the object that the JSP container has processed back to the client. The response object also has scope, which is valid only within the JSP page.

3. Session Object

The Session object is an object that is automatically created by the server that is related to the user request. The server generates a Session object for each user that holds the user's information and tracks the user's operational status. The session object uses the map class internally to hold the data, so the format of the saved data is "Key/value". The value of the session object can make complex object types, not just string types.

4. Application Object

The Application object saves information in the server until the server shuts down, otherwise the information saved in the Application object will be valid throughout the application. The Application object has a longer life cycle than the session object, similar to the system's global variables.

5. Out Object

The Out object is used to output information within a Web browser and to manage the output buffers on the application server. When you use an Out object to output data, you can manipulate the data buffers to clear the remaining data in the buffer and make buffer space for the other output. When the data output is complete, the output stream should be closed in time.

6. PageContext Object

The function of the PageContext object is to obtain any range of parameters, through which 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, and the PageContext object can be used directly in the JSP page.

7. config Object

The main purpose of the Config object is to obtain the server configuration information. A config object can be obtained by using the Getservletconfig () method of the Pageconext object. When a servlet initializes, the container passes some information through the Config object to the servlet. Developers can provide initialization parameters for servlet programs and JSP pages in the application environment in the Web. xml file.

8. Page Object

The Page object represents the JSP itself and is only legal within the JSP page. The page implied object essentially contains the variables referenced by the current servlet interface, similar to the this pointer in Java programming.

9. Exception Object

The purpose of the exception object is to display exception information that can be used only on pages that contain iserrorpage= "true", which will not compile JSP files in a generic JSP page. The Excepation object, like all objects in Java, has a system-provided inheritance structure. The exception object almost defines all exception conditions. In Java programs, you can use the Try/catch keyword to handle exceptions, and if an exception is not caught in the JSP page, the exception object is generated and the exception object is routed to the error page set in the page directive. The corresponding exception object is then processed in the error page.

JSP nine large built-in objects: request, response, session, application, out, page, PageContext, config, exception

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.