JSP session, request

Source: Internet
Author: User

application and session are relatively simple. The scope of application and page is described here.
application: global scope. The entire application Program is shared, that is, the same webapp in the deployment file is shared, and the lifecycle is: the application starts to stop.
session: indicates the session scope. When a user accesses a session for the first time, a new session is generated, and the server can remember the session status. Life cycle: the session times out, or the server forces the session to fail.
request: Request scope, which is a client request.
page: a JSP page.
the above scope is getting smaller and smaller, and the request and page lifecycles are short. The difference between them is that a request can contain multiple page (include, forward and filter ). For example,
jsp1.jsp

jsp2.jsp

RUN jsp1.jsp to display data normally, because the scope of function is request, it is equivalent to calling request. setattribute () method. The jsp2 page passes the request. getattribute to obtain the bean. if you change the request to page, nullpointereffectioin will be thrown.
a single request can span several JSP (include and forword) and Servlet (such as filter ). however, the difference between
; and <% @ include>. if the preceding is changed to <% @ include file = "jsp2.jsp" %>, even if the scope is page, <% @ include %>; it is included during compilation, and it is included during runtime. the former is equivalent to a macro, which is replaced during compilation, and the latter is equivalent to a function, which is returned at runtime.

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.