Nine implicit objects in jsp and nine hidden objects in jsp

Source: Internet
Author: User

Nine implicit objects in jsp and nine hidden objects in jsp

I. Why do we need implicit objects?

1. Simplified JSP page development,
2. The implicit object name is a reserved word of JAVA,
3. Implicit objects do not need to be instantiated,

4. Access the dynamic content of a webpage through implicit objects. JSP implicit objects are a group of classes loaded by web containers.


Ii. Classification of nine implicit objects



3. Functions of each object.

(1) Application

Global scope: indicates the Web module (Application) during the entire runtime)

(2) Seesion

Session scope: indicates the current HTTP session

(3) Request

Request scope: indicates the current HTTP Request

(4) Pagecontext

Page scope: the context of the current JSP page. Because the context of a JSP page includes the current request, session, and application procedure, you can use the pageContext instance to access all namespaces related to a JSP page.

(5) ResponseResponse object

(6) Page: Current Page Object

(7) Config: servletConfing/FilterConfig object

(8) Out: Output object

(9) Exception: Exception


Iv. Scope and lifecycle of the four domains

(1) Create pageContext when executing pageContext jsp and destroy pageContext when jsp page ends (2) create a request when requesting the server and terminate request destruction

(3) When the session client requests the server for the first getSession, the server creates a session. The session has not been used for xx (or the session. invalidate method is called), and the server destroys the session.

(4) The application (servletContext) web application is created when it is started, and the web application is destroyed when it is stopped.


5. Domain usage Problems

(1). Under what circumstances do I use the request domain? If the data is useless after reading the data during development, the data should be stored in the request domain. For example, when you read news, the news is useless data when you read it. When the servlet obtains news data, it should be displayed in the request to jsp.

(2). Under what circumstances will the session domain be used? If the user still needs to use the data after reading the data during program development, the data should be stored in the session domain. for example, the purchased item is user data. After the data is generated, the user needs to wait for a while for checkout. Then, the program should store the data in the user's session.

(3). Under what circumstances will the application domain be used? If the data is generated during the development of the program, the data will not only be used for a while, but also for others, it should exist in the application domain, such as web chat rooms and user chat data, this data is not only visible to users for a while, but also to others.



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.