Turn from:page,request,session,application four domain objects use and differences
1.page refers to the current page. Valid only on one JSP page.
2.request refers to the entire process of returning a response from an HTTP request to the end of the server processing. Use the forward method to jump through multiple jsps during this process. You can use this variable on these pages.
3.Session valid range current session, from browser open to browser close this process.
4.application its effective range is the entire application.
The variables in the scope, they survive the longest, and if they are not manually deleted, they can be used all the time.
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 you refresh the page, they recalculate.
The variables in the session and the application always accumulate, and at the beginning there is no difference, as long as you close the browser and restart the browser to access the page again, the variables in the session are recalculated.
The variables in the application keep accumulating until you restart Tomcat, otherwise it will keep getting bigger.
The scope specifies the validity period of the variable.
If you put the variable in the PageContext, it means that its scope is page, its valid range is only in the current JSP page.
You can use this variable from the start of placing the variable in PageContext to the end of the JSP page.
If you put the variable in the request, it means that it is scoped to request, and its valid range is the current demand period.
The so-called request period, that is, from the HTTP request initiation, to the end of the server processing, return the entire process of response. You may use forward to jump through multiple JSP pages in this process, and you can use this variable in these pages.
If you put the variable in the session, it means that it is scoped to the session, and its valid range is the current one.
The so-called current session refers to the process of opening the browser from the user to the user closing the browser. This process may contain multiple request responses. In other words, 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 entire process is called a session, and the variables placed in the session can be used in all 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 entire application.
The entire application is launched from the app to the end of the app. We did not say "boot from server to server shutdown" because a server might deploy multiple applications, and of course you shut down the server and shut down all of the applications.
Application The variables in the scope, they survive the longest, and if not manually deleted, they can be used all the time.
Unlike the three above, the variables in the application can be shared by all users. If user A's operation modifies the variable in application, the User B gets the modified value when he accesses it. This will not happen in any other scope, page, request, session is completely isolated, regardless of the modification will not affect other people's data.
The scope of the PageContext object applies only to the current page range, which means that more than this page can be used. Therefore, it is not possible to use the PageContext object to pass parameters to other pages.
The scope of the request object is when a JSP Web page makes a request to another JSP Web page, and then this property is invalidated.
The session is scoped to the length of time a user continues to connect to the server, but this property is invalid when disconnected from the server. such as breaking the net or closing the browser.
The scope of the application executes the service at the beginning of the server, until the server shuts down. It has the largest range and the longest life cycle.
Page,request,session,application the use and difference of four domain objects