The difference between Page, request, session, application four domains

Source: Internet
Author: User

1. Simply say page refers to the current page. Valid in a JSP page


2.request refers to the entire process of returning a response from an HTTP request to the end of a server processing. In this process, use the forward method to jump multiple JSPs. You can use this variable on these pages.


3.Session Active Range Current session, open from browser to browser close this procedure.


4.application its effective range is the entire application.


Variables in the scope, they have the longest surviving time, and if they are not deleted manually, they can always use the


The variables in page cannot be passed from index.jsp to test.jsp. As soon as the page jumps, they are gone.


The variables in the request can span two pages before and after forward. But as soon as the page is refreshed, they are recalculated.

Session and application in the variable has been cumulative, beginning to see no difference, as long as the browser closed, restart the browser to access this page, the session in the variables are recalculated.
The variables in the application are accumulating, and unless you restart Tomcat, it will keep getting bigger.


The scope stipulates the validity period of the variable.


If you put a variable in the PageContext, it means that it's scoped to page, and its valid range is only in the current JSP page.

You can use this variable from the beginning of the PageContext to the end of the JSP page.


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


The so-called request cycle, that is, from the HTTP request, to the end of the server processing, return the entire process of response. In this process, you may use forward to jump through multiple JSP pages, where you can use this variable.


If you put the variable in the session, it means that its scope is the sessions, and its valid range is the current conversation.


The current session, that is, from the user opened the browser to start, to the user to close the browser in the middle of the process. This process may contain multiple request responses. That is, as long as the user does not close the browser, the server has the means to know that these requests are initiated by a person, the whole process is called a session, and placed in the session of the variable, can be used in all the requests of the current conversation.

If you put the variable in the application, it means that its scope is application and its effective range is the whole application.

The entire application is started from the application to the end of the application. We did not say "boot from server to server shutdown" because a server might deploy multiple applications, and of course, if you shut down the server, all of the above applications would be shut down.

The variables in the scope of the application, which have the longest surviving time, are always available if they are not deleted manually.

Unlike the three above, the variables in application can be shared by all users. If user A's action modifies a variable in application, User B accesses the modified value. This will not happen in any other scope, page, request, session are completely isolated, no matter how the modification will not affect the data of other people.

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.