When each JSP page is accessed for the first time, the WEB Container will send the request to the JSP Engine (a Java program) for processing. The JSP Engine first translates JSP into a _ jspServlet (essentially a servlet) and calls it according to the servlet call method.
Since JSP is translated into servlet during the first access, the first access is usually slow, but the second access, if the JSP Engine finds that JSP has not changed, it will not translate but directly call it, therefore, the execution efficiency of the program will not be affected.
When the JSP Engine calls the _ jspServlet corresponding to JSP, nine web development-related objects will be passed or created for _ jspServlet. To facilitate developers to obtain the reference of these web objects when compiling JSP pages, the JSP technology designer specially defines nine corresponding variables, developers can use these variables on the JSP page to quickly obtain references to these nine objects.
What are these nine objects and their functions are also the knowledge points frequently examined by the written examination.
Jsp nine implicit objects
Request // indicates the request object
Response // represents the response object
Config // represents the servletConfig object
Application // represents the servletContext object
Exception
Session
Page
Out // represents response. getWriter (), the character output stream object
PageContext
PageContext object
PageContext objects are the most important objects in JSP technology. They represent the running environment of JSP pages.
This object not only encapsulates references to other 8 hidden objects,
It is a domain object and can be used to save data.
In addition, this object also encapsulates some common operations that are often involved in web development, such as introducing and redirecting other resources and retrieving attributes in other domain objects.
Get other objects through pageContext
The getException method returns the exception implicit object.
The getPage method returns the page implicit object.
The getRequest method returns the request implicit object.
The getResponse method returns the response implicit object.
The getServletConfig method returns an implicit config object.
The getServletContext method returns the application implicit object.
The getSession method returns a session implicit object.
The getOut method returns an out implicit object.
PageContext encapsulates the meaning of the other eight built-in objects. Think: If the pageContext object is passed to a common java object during programming, what functions will this java object have?
PageContext as a domain object
PageContext object Method
Public void setAttribute (java. lang. String name, java. lang. Object value)
Public java. lang. Object getAttribute (java. lang. String name)
Public void removeAttribute (java. lang. String name)
The pageContext object also encapsulates methods for accessing other domains.
Public java. lang. Object getAttribute (java. lang. String name, int scope)
Public void setAttribute (java. lang. String name, java. lang. Object value, int scope)
Public void removeAttribute (java. lang. String name, int scope)
Representing constants of various domains
PageContext. APPLICATION_SCOPE
PageContext. SESSION_SCOPE
PageContext. REQUEST_SCOPE
PageContext. PAGE_SCOPE