Scope of page, request, session, and application in JSP

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.