Details of the usage of pageContext object

pageContext object This object represents the page context, which is mainly used to access shared data between JSPs.

 pageContext is an instance of the PageContext class. Using pageContext, you can access variables in the scope of page, request, session, and application.     

 getAttribute(String name): Get the name attribute within the page scope. 

 setAttribute(String name, value, int scope): If no scope is specified, the attribute defaults to the page scope, such as: pageContext.setAttribute("page","hello");  

Use pageContext to set attributes in the request scope pageContext.setAttribute("request2","hello" , pageContext.REQUEST_SCOPE);  

Use pageContext to set attributes in session scope pageContext.setAttribute("session2","hello" , pageContext.SESSION_SCOPE); 

 Use pageContext to set attributes in the application scope pageContext.setAttribute("app2","hello" , pageContext.APPLICATION_SCOPE);    

 getAttribute(String name,int scope): Get the name attribute within the specified scope,

Where scope can be the following 4 values:

 PageContext.PAGE_SCOPE: corresponds to the page scope. 

 PageContext.REQUEST_SCOPE: corresponds to the request scope. 

 PageContext.SESSION_SCOPE: corresponds to the session scope. 

 PageContext.APPLICATION_SCOPE: corresponds to the application scope.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325770733&siteId=291194637