The page property range (denoted by PageContext, but is generally used to refer to this range as the page range) indicates that a property is set on this page and cannot be obtained after the page jumps.
Let's write two small examples to test:
1. Set a property on the same JSP page and take out the properties:
1<%@ page contenttype= "text/html; Charset=utf-8 "language=" java "errorpage=" "%>2<%@ pageImport= "Java.util.*"%>3<!doctype html>456<meta charset= "Utf-8" >7<title>page Attribute Range </title>89 Ten<body> One<% APagecontext.setattribute ("name", "Ninic"); -Pagecontext.setattribute ("Birthday",NewDate ()); -%> the<% -String Username= (String) pagecontext.getattribute ("name"); -Date userbirthday= (date) pagecontext.getattribute ("Birthday"); -%> + - +</body> A
Displayed in the browser:
2. Set properties on different pages and remove attributes
(1) page_demo.jsp
1<%@ page contenttype= "text/html; Charset=utf-8 "language=" java "errorpage=" "%>2<%@ pageImport= "Java.util.*"%>3<!doctype html>456<meta charset= "Utf-8" >7<title>page Attribute Range </title>89 Ten<body> One<% APagecontext.setattribute ("name", "Ninic"); -Pagecontext.setattribute ("Birthday",NewDate ()); -%> the<jsp:forward page= "page_demo2.jsp"/> -</body> -
(2) page_demo2.jsp
1<%@ page contenttype= "text/html; Charset=utf-8 "Language=" Java "Import= "java.util.*" errorpage= ""%>2<!doctype html>345<meta charset= "Utf-8" >6<title> Untitled Document </title>78 9<body>Ten<% OneString Username= (String) pagecontext.getattribute ("name"); ADate userbirthday= (date) pagecontext.getattribute ("Birthday"); -%> - the -</body> -
Displayed in the browser:
JSP_ Attribute Range _page