Introduction to the use of JSP related objects
- 2020-05-26 09:55:42
- OfStack
JSP9 great implicit objects:
Object name describe scope The data type request This object encapsulates the details (parameters, properties, headers, and data) of HTTP requests generated by WEB browsers or other clients. request (user request period) A subtype of ServletRequest response This object encapsulates the output returned to the HTTP client, providing the page author with a way to set the response header and status code. It is often used to set the HTTP title, add cookie, set the type and state of the response content, send HTTP redirection and encode URL; page (page execution period) A subtype of ServletResponse session Mainly used for tracking conversations; HttpSession is a hash table-like object associated with a single 1WEB browser session. It exists between HTTP requests and can store objects of any type. If you do not need to track session objects between requests, you can specify session="false" in the page directive. session (during the session) javax. servlet. http HttpSession type application The servlet environment is obtained by calling the getServletConfig().getContext () method, which provides information about the server version, application-level initialization parameters and the absolute path of in-application resources, and the way to register information. application (entire program run time) javax. servlet. ServletContext type config Object provides some configuration information. Common methods are getInitParameter and getInitParameterNames to get the parameters for the initialization of Servlet. page (page execution period) javax. servlet. ServletConfig type page The page directive is used to define various attributes of the JSP page. No matter where the page directive appears on the JSP page, it serves the entire JSP page. In order to keep the program readable and follow good programming habits, the page directive is best placed at the beginning of the entire JSP page. page (page execution period) java. lang. Object type out An object representing an output stream; page (page execution period) javax. servlet. jsp JspWriter type exception URI of errorPage is propagated through any instance of java.lang.Throwable in the JSP error page where an catch block has been extracted but not captured. Note :exception is only valid if isErrorPage="true" in the page instruction; page (page execution period) java. lang. Throwable type pageContext The PageContext class defines one forward method and two include methods to simplify and replace the RequestDispatcher.forward and include methods, respectively. This object provides the ability to query and modify properties at all four scoped levels. It also provides the means to forward requests to and include other resources. page (page execution) javax. servlet. jsp. PageContext (abstract class) typeThe @1:pageContext object can also be obtained and set session properties in the same way as session.getAttribute (), session.setAttribute ()1.
JSP4 large domain objects:
pageContext request Session ServletContext Page range Request scope Session scope Application scope