Java Web Review Summary (6) - jsp - Built-in Objects - Introduction - page,out

When used , a development-related object _jspServletis passed or created for use.9web_jspServlet

JSPIn order to facilitate developers to JSPobtain references to these objects when writing pages, the designer of the technology has webspecially defined 9a corresponding variable

Developers JSPcan quickly obtain 9a 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: JSPInside, pageis the JSPcurrent object of the page, similar to the JSPpage's this.

request: is HttpServletRequestthe object of the class, as mentioned before ( pageContextby getRequest()returning is ServletRequest, there is a distinction)

session: HttpSessionobject of the class, but not every JSPpage can share the sessionobject, if it is JSPspecified before a page, <%@ page session="false" %>it cannot be used on the pagesession

application: ServletContextthe object of the class.

pageContext: That is PageContext, the object of the class, the page context object.


Built-in object specification

1. page object

  pageThe object represents the current JSPpage, which can be understood as an object itself
  , that is : treat one JSPas an object. pageObjects 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 by pageContext calling the getOut method of the object
Its action and ServletResponse.getWriter usage PrintWriter is very similar to the object returned by the method.
Nature:
JSP The type of the out object JspWriter , which is JspWriter equivalent to a cache function PrintWriter
Setting a JSP page 's page directive buffer properties can adjust its cache size or even turn off its cache.
working principle:

Assad
outWhen the object needs to meet any of the following conditions, the object will outcall PrintWriterthe object to process the content in its own buffer
and write it into the Servletprovided buffer after conversion, and then display it on the page:

Delivery conditions:
1. Setting pagethe property of the instruction bufferturns off the outobject's caching function
2. The outobject's buffer is full
3. The entire JSPpage ends

Guess you like

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