Application and Session are relatively simple, here mainly illustrate the scope of REQUEST and PAGE.
Application: Global action range, the entire application sharing, is the same webApp share in the deployment file, the lifecycle is: the application starts to stop.
Session: Session Scope, when the user first accesses, generate a new session, and later the server can remember this session state. Lifecycle: Session timeout, or server-side enforcement to invalidate session.
Request: Request a scope, is a request for the client.
Page: A JSP page.
The above scope is made smaller and smaller, the life cycle of Request and Page is short, and the difference between them is: A Request can contain multiple Page Pages (including, Forward, and Filter). Lift a simple example:
JSP1.jsp
JSP2.jsp
Running jsp1.jsp can display data normally because the scope is request, which is equivalent to calling the request.setttribute () method,
The JSP2 page will get this bean via Request.getaTribute. If you change the request to Page, you will throw NullPointeredExceptiin.
A request can span several JSP (include and forward) and servlets (such as filter). However, there is a difference between you need to pay attention to it.