Jsp nine built-in objects and four domain objects

1. Nine built-in objects

  (1) request HttpServletRequest
  (2) response HttpServletResponse
  (3) config ServletConfig
  (4) application ServletContext
  (5) session HttpSession
  (6) exception Throwable
  (7) page Object(this)
  (8) out JspWriter
  (9) pageContext PageContext

2. Four major domain objects (the first three are also the three domain objects of Servlet)

  1. HttpSession

    (1) Use: call the request.getSession() method.

    (2) Life cycle: When the request.getSession() method is called for the first time, the server will check whether there is a corresponding session, if not, create a session in memory and assign an id to return. When the session is not used for a period of time (the default is 30 minutes), the server will destroy the session; if the server is shut down abnormally, the session that has not expired will also be destroyed; if the invalidate() provided by the session is called, it can be destroyed immediately session.

       Note: The server is normally shut down and restarted, and the Session object will be passivated and activated. At the same time, if the server passivation time is within the default session destruction time, the session still exists after activation, otherwise the session does not exist.

  2. ServletRequest

    (1) Use: call the request method.

    (2) Life cycle: It is created by the server before the service method is called, and the service method is passed in. The entire request ends, and the request life ends.

  3. ServletContext

    (1) Use: call the request.getSession().getServletContext() or this.getServletContext() method.

    (2) Life cycle: When a web application is loaded into the container, a ServletContext object representing the entire web application is created and exists globally. When the server is shut down or the web application is removed, the ServletContext object is destroyed.  

  4. PageContext

    (1) Use: call PageContext pageContext = javax.servlet.jsp.JspFactory.getDefaultFactory().getPageContext(this, request, response, null, true, 8192, true) method (Servlet calling method)

    (2) Life cycle: It starts when a request to JSP is made, and it is destroyed when the response ends.  

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738034&siteId=291194637