JSP:Page,Request,SessionAnd Application. PageThe range of JSP pages on a single page; RequestThe range is only between one JSP page and the other, and this attribute becomes invalid; SessionThe range is the time when the user and the server are connected, and the disconnection attribute between the user and the server becomes invalid; ApplicationIt has the largest scope of application and is used with caution. The service is executed at the beginning of the server until the server is closed. This may cause heavy server load.Some programmers classify requext, session, application, and pagecontext as one type because they can use setattribute () and getattribute () to set and obtain the attribute, use these two methods to share data. But what are their differences? The biggest difference between them is that the scope is different. Next I will briefly introduce their differences... Page The so-called page refers to the range of a single page JSP page. To save data to the page range, you can use the pagecontext object Setattribute () method and getattribute () method. Request The request range refers to the failure of this attribute when a JSP page sends a request to another JSP page. Session Session is used for a period of time when a user is connected to IOT platform. However, this attribute is invalid when the session is disconnected from the server. When a session object is input, the data range is session. Application The scope of application is to execute services at the beginning of the server. The maximum range of application is reached until the server is closed, and the maximum stay time is reached, Therefore, pay special attention to the usage. Otherwise, the server load may become more and more serious. The following lists the methods for storing and retrieving attributes that can be used by request, session, application, and pagecontext. Void setattribute (string name, object Value): set the value of the name attribute to value. Enumeration getattributenamesinscope (INT scope) gets attributes of all scope ranges Object getattribute (string name) obtains the value of the name attribute. Void removeattribute (string name) removes the value of the name attribute. Note: pagecontext does not have the getattributenames () method. |