Introduction to the use of JSP related objects _jsp programming

Source: Internet
Author: User
Tags throwable

JSP nine large implicit objects:

Object Name Describe Scope Data type
Request This object encapsulates the details (parameters, attributes, headers, and data) of HTTP requests generated by Web browsers or other clients; Request (user requested period) ServletRequest of the child type
Response This object encapsulates the output returned to the HTTP client and provides a way for the page author to set response headers and status codes. Often used to set HTTP headers, add cookies, set the type and status of response content, and send HTTP redirects and coded URLs; page (pages execution period) Servletresponse of the child type
Session Primarily used to track conversations; HttpSession is a hash-like object that is associated with a single Web browser session, exists between HTTP requests, can store any type of object, and if you do not need to track session objects between requests, you can specify session= in the page directive by specifying the "False", note: @1; Session (during sessions) Javax.servlet.http.HttpSession type
Application The context of the servlet is obtained by calling the Getservletconfig(). GetContext () method, which provides information about the server version, application-level initialization parameters, and the absolute path of the resource within the application, the way in which it is registered, and common methods Getrealpath () ; Application (whole program running period) Javax.servlet.ServletContext type
Config Object provides configuration information, and commonly used methods include Getinitparameter and getinitparameternames to obtain the parameters for servlet initialization. page (pages execution period) Javax.servlet.ServletConfig type
Page The page directive is used to define the various attributes of the JSP page, regardless of where the page instruction appears in the JSP pages, it acts as the entire JSP page, in order to keep the program readable and follow good programming habits, the page instruction is best placed at the beginning of the entire JSP page; page (pages execution period) Java.lang.Object type
Out An object representing the output stream; page (pages execution period) Javax.servlet.jsp.JspWriter type
exception Any instance of a java.lang.Throwable that has been benefited from a catch block in the JSP error page, but not captured, is passed to the ErrorPage URI, note: Exception is valid only if there is a property iserrorpage= "true" in the page directive; page (pages execution period) Java.lang.Throwable type
PageContext A forward method and two include methods are defined in the PageContext class to simplify and replace Requestdispatcher.forward methods and include methods respectively; This object provides property query and modification capabilities at all four scoping levels, and it also provides methods for forwarding requests to other resources and including other resources; page (pages execution period) Javax.servlet.jsp.PageContext (abstract Class) type

The @1:pagecontext object can also obtain and set session properties in the same way as Session.getattribute (), Session.setattribute ().

JSP four domain objects:

pagecontext request Session servletcontext
page range request range Session scope application-scoped
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.