The scope attribute is used to specifyStorage domain rangeThe value can only be one of the four values: Page, request, session, and application. The default value is page.
 
I can test the following code:
 
Date. jsp
 
---------------------------------------------------------
 
<JSP: usebean id = "currentdate" class = "Java. util. Date" Scope = "request"/>
<% = Currentdate. tostring () %>
 
 
 
Test results:
 
1. When scope = application, we browse date. jsp, and the system time is displayed. However, no matter how we refresh it, open another browser, or even change the server, the display time remains the same, it is the original time (that is, the system time obtained when bean was just created ), because scope = application, the JavaBean instance has only one copy in the memory. At this time, as long as the Web service is not restarted, the output will not change.
 
2. When scope = session, browsing date. jsp will not change during refresh. However, when we re-open a browser, that is, a new session, the system will create a JavaBean instance again to get the current system time, then the correct time will be obtained. Similarly, if you refresh the newly opened page again, the display will not change.
 
3. When scope = page/request, the page will be refreshed continuously to get the current system time.
 
 
 
Meanings and functions of each set value of the scope attribute:
 
(1) page indicatesJavaBean Instance ObjectStored inPagecontext objectIs effective on the current JSP page.
 
(2) request indicates that the JavaBean instance object is stored in the servletrequest object. the JavaBean object stored in the request object can be accessed by all servlets and JSP pages in the same request.
 
(3) session indicates that the JavaBean instance object is stored in the httpsession object. the JavaBean object stored in the httpsession object can be accessed by all servlets and JSP pages belonging to the same session, this setting requires that the current JSP page supports session, that is, the session attribute of the page command is not set to false. That isA specific userValid: An http session.
 
(4) application indicates that the JavaBean instance object is stored in the servletcontext object. the JavaBean object stored in the servletcontext object can be accessed by all servlets and JSP pages in the same web application. That isAll usersCan be used.