Four ranges developed by Drp-web

Source: Internet
Author: User
Tags ranges

Looking at the DRP recently, Wang Yong talked about the four areas of web development, access to information, plus their feelings and share with you, compared to the previously learned ASP.

A. Brief introduction:

page (JSP valid) request (one request) session (one session) application (current Web App) page field refers to PageContext.; The request domain refers to a requesthttpservletrequest;session field that refers to a sessionhttpsession;application domain that refers to a applicationservletcontext
The reason they are domain objects is that they all have built-in map collections, all with the SetAttribute getattribute method. They all have their own fixed life cycle and scope. The life cycle of these four objects (the life cycle is the creation of value objects into the period of destruction):
The Declaration period for four domain objects:
The page:jsp page is executed, the life cycle begins, the JSP page executes, and the declaration period ends.
Requests: The user sends a request, starts, the server returns a response, the request ends, and the life cycle ends.
Session: The user opens the browser access, creates the session (start), the session timeout or is declared invalid, the object life cycle ends.

Application:web is created when the application loads. The web app is removed or the server shuts down and the object is destroyed. [end].

Two. Note:

The page is valid only in the current JSP, each request corresponds to a different request;request only in the current request valid, each request corresponding to the different request domain; Four domain objects, when selected, can never use a range of small range: page: The data is only a temporary collection, in the JSP page other places to use, with page (custom map in the pages).

Request: The data is only shown, it is useless to read it. In the request domain, requests forwarding, servlet generated processing results (data) to the JSP display, data forwarding can take data.

Session: The data to the user to read, must also use, the end of the session is useless.
User login, user information to the client to see, after reading, a visit to other pages also depends on user information.
Shopping cart, Shopping cart success, to the user to see the shopping cart, will be able to view the shopping cart over time.
Request redirection, because it is two requests, each request data, the second request also to see.

Application: Data to a user ran out, others need to use.
Chat rooms, chat logs, need to be seen by all users.
Statistics website online number, all see should be a number.
Three. Summary:
Four domain objects in the selection, can use a small range of never use a large range. It is better to define a map than to use the page, request the servlet, forward to the JSP data memory request, redirect with the past data storage session, the global data storage application. The DRP video is the most detailed I have ever seen and the seriousness of Wang Yong's teacher deeply infected himself.

Four ranges developed by Drp-web

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.