When used , a development-related object _jspServlet
is passed or created for use.9
web
_jspServlet
JSP
In order to facilitate developers toJSP
obtain references to these objects when writing pages, the designer of the technology hasweb
specially defined9
a corresponding variable
Developers JSP
can quickly obtain 9
a reference to this large object through these variables in the page.
built-in objects
built-in objects | Types of |
---|---|
pageContext |
javax.servlet.jsp.PageContext |
request |
javax.servlet.http.HttpServletRequest |
response |
javax.servlet.http.HttpServletResponse |
session |
javax.servlet.http.HttpSession |
application |
javax.servlet.ServletContext |
config |
javax.servlet.ServletConfig |
out |
javax.servlet.jsp.JspWriter |
page |
java.lang.Object |
exception |
java.lang.Throwable |
request
, the
response
object has been used and said before, it will not be explained here
session
,
application
, the
config
object is explained in other chapters, and will be added later
pageContext
Object ,
out
object,
page
object are classified into one category
simple understanding
page
: JSP
Inside, page
is the JSP
current object of the page, similar to the JSP
page's this
.
request
: is HttpServletRequest
the object of the class, as mentioned before ( pageContext
by getRequest()
returning is ServletRequest
, there is a distinction)
session
: HttpSession
object of the class, but not every JSP
page can share the session
object, if it is JSP
specified before a page, <%@ page session="false" %>
it cannot be used on the pagesession
application
: ServletContext
the object of the class.
pageContext
: That is PageContext
, the object of the class, the page context object.
Built-in object specification
1. page object
page
The object represents the current JSP
page, which can be understood as an object itself
, that is : treat one JSP
as an object. page
Objects are hardly used in development, just get to know them
2. out object
- effect:
-
out
Objects are used to send textual data to clients. - Obtain:
-
out
The object is obtained bypageContext
calling thegetOut
method of the objectIts action and
ServletResponse.getWriter
usagePrintWriter
is very similar to the object returned by the method. - Nature:
-
JSP
The type of theout
objectJspWriter
, which isJspWriter
equivalent to a cache functionPrintWriter
Setting a
JSP
page 'spage
directivebuffer
properties can adjust its cache size or even turn off its cache. - working principle:
-
out
When the object needs to meet any of the following conditions, the object willout
callPrintWriter
the object to process the content in its own buffer
and write it into theServlet
provided buffer after conversion, and then display it on the page:Delivery conditions:
1. Settingpage
the property of the instructionbuffer
turns off theout
object's caching function
2. Theout
object's buffer is full
3. The entireJSP
page ends