1. Page: Current pages
2. Request: In a single server jump range
3. Session: Once user operation range, reopen browser invalidation
4. Application: The entire server is saved and the server shuts down.
Define a Count.java and put it in web-info\classes.
Package Cn.mldn.lxh.demo; Public class count { privateint count = 0 ; Public count () { System.out.println ("=========== a new Count object produces ==========="); } Public int GetCount () { returnthis. Count; }}
Define a page to save the scope of the JSP file:
class= "Cn.mldn.lxh.demo.Count"/><body>
Jump to 02:
class= "Cn.mldn.lxh.demo.Count"/><body>
Server-side display "A new count object generated" number of times: 2
Refresh page display number of visits: 1.
So if you want to be effective when the server jumps, use request:
01:
class= "Cn.mldn.lxh.demo.Count"/><body>
02:
class= "Cn.mldn.lxh.demo.Count"/><body>
Server-side display "A new count object generated" number of times: 1
Number of Visits: 2
Session mode:
class= "Cn.mldn.lxh.demo.Count"/><body>
Server-side display "A new count object generated" Count: 1, not created after refresh
Number of Visits: +1
When opening a new browser:
Server-side display "A new count object generated" number of times: 1
Number of Visits: +1
Application Way:
class= "Cn.mldn.lxh.demo.Count"/><body>
Server-side display "A new count object generated" count: not refreshed
Number of visits: 6,7,8 ...
Summarize:
As in the JSP4 range, the difference: the page range is not PageContext, you can specify directly
javabean--Save Range