Four Scopes in JSP

Source: Internet
Author: User
  1. If you put the variable in pagecontext, it indicates that its scope is page, and its valid range is only in the current JSP page.

    You can use this variable from placing it in pagecontext to the end of the JSP page.

  2. If you put the variable in the request, it indicates that its scope is request, and its valid range is the current request cycle.

    The request cycle refers to the whole process from initiating an HTTP request to processing the server and returning a response. In this process, you may use the forward method to jump to multiple JSP pages. You can use this variable in these pages.

  3. If the variable is put into the session, it indicates that its scope is session, and its valid range is the current session.

    The current session refers to the process from when the user opens the browser to when the user closes the browser. This process may contain multiple request responses. That is to say, as long as the user is not in the browser, the server can know that these requests are initiated by a person. The whole process is called a session and put into the session variable, it can be used in all requests of the current session.

  4. if you put a variable in the application, it indicates that its scope is application, its effective scope is the entire application.

    the entire application starts from the application and ends with the application. We didn't say "starting from the server to shutting down the server" because one server may deploy multiple applications. Of course, if you close the server, all the above applications will be shut down.

    variables in the application scope have the longest survival time, if you do not delete them manually, they can be used all the time.

    unlike the preceding three methods, the variables in the application can be shared by all users. If user a's operations modify the variables in the application, user B obtains the modified value during access. This will not happen in other scopes. pages, requests, and sessions are completely isolated, and data of others will not be affected no matter how modified.

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.