Nine built-in JSP objects and JSP built-in objects

Source: Internet
Author: User

Nine built-in JSP objects and JSP built-in objects

JSPs have nine built-in objects: request, response, session, application, out, pagecontext, config, page, and exception.

1. request object:Client request information, mainly receives data transmitted to the server through http. Scope: one request

2. response object:The response to the client mainly refers to sending the processed objects of the jsp Container Back to the client. Scope: Valid only on the jsp page

3. session object:Session trace. Internally, the map class is used to save the data "key/value" (value can be a complex object type, not limited to strings)

4. application object:Save the information on the server until the server is closed. Longer than the session lifecycle, similar to the system's "global variables"


5. out object:Outputs Information in a web browser and manages the output buffer on the application server. When you use an out object to output data, you can operate on the data buffer, and immediately clear the residual data in the buffer, giving up the buffer space for other outputs. After the data is output, close the output stream in time.


6. pageContext object:You can obtain parameters in any range. It can be used to obtain the out, request, response, session, application, and other objects of the jsp page. The creation and initialization are completed by the container. PageContext can be used directly on jsp pages.


7. config object:The main function is to obtain the server configuration information. Get the config object through getServletConfig () of pageContext. When a servlet is initialized, the container passes some information to the servlet through the config object. 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 valid only on the jsp page. The page implicit object essentially contains the variables referenced by the current Servlet interface, similar to the "this" pointer in java.


9. exception object:The function is to display exception information, which can only be used on pages that contain isErrorPage = "true". If this object is used on a common jsp page, jsp files cannot be compiled. The annotation object is the same as all Java objects and has the inheritance structure provided by the system. The exception object defines almost all exceptions. In Java programs, you can use the try/catch keyword to handle exceptions. If exceptions are not caught on the JSP page, an exception object is generated, transfer the exception object to the error page set in the page command, and then process the exception object on the error page.

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.