Introduction to four major jsp scopes and four major jsp scopes

Source: Internet
Author: User

Introduction to four major jsp scopes and four major jsp scopes

Four Scopes

In Web applications, JSP-created objects have a certain lifecycle and may be accessed by other components or objects. The object declaration cycle and accessibility are called scopes. The scope of the four range objects ranges from small to large: pageContext ---- request ---- session ---- application.

(1) pageContext: Page domain

The page scope is limited to the current page object. It can be similar to this object of java. If you leave the current JSP page (whether redirect or forward), all attribute values in pageContext will be lost.

(2) request: request domain

The request scope is within the same request. During page Jump, if you use the forward method to redirect, the forward target page can still get the attribute value in the request. If a page is redirected through redirect, because redirect is equivalent to sending a new request, the attribute values in the request will be lost in this scenario.

(3) session: session domain

The session scope is within the life cycle of a session. If the session fails, the data in the session is also lost.

(4) application: application domain

The application scope is the largest. As long as the server does not stop, the application object always exists and is shared by all sessions.

Related Article

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.