Introduction to JSP-related objects

Source: Internet
Author: User

Nine implicit JSP objects:

Object Name Description Scope Data Type
Request This object encapsulates the details (parameters, attributes, header labels, and data) of HTTP requests generated by WEB browsers or other clients ); Request (user request period) Subtype of ServletRequest
Response This object encapsulates the output returned to the HTTP client and provides the page author with the method of setting the response header and status code. It is often used to set HTTP headers, add cookies, set the type and status of the response content, and send HTTP redirection and encoded URLs; Page (page execution period) Subtype of ServletResponse
Session HttpSession is an object similar to a hash table related to a single WEB browser session. It exists between HTTP requests and can store any type of objects, if you do not need to track session objects between requests, you can specify session = "false" in the page command. Note: @ 1; Session) Javax. servlet. http. HttpSession type
Application The servlet environment calls getServletConfig (). the getContext () method provides the following methods: Server version, application-level initialization parameters, absolute path of resources in the application, and registration information. getRealPath () is a commonly used method (); Application (throughout the program running) Javax. servlet. ServletContext type
Config The object provides some configuration information. Common methods include getInitParameter and getInitParameterNames to obtain the Servlet initialization parameters. Page (page execution period) Javax. servlet. ServletConfig type
Page The page command defines various attributes of a JSP page. No matter where the page command appears on a JSP page, it serves the entire JSP page, in order to keep the program readable and follow good programming habits, the page instruction should be placed at the beginning of the entire JSP page; Page (page execution period) Java. lang. Object Type
Out Indicates the object of the output stream; Page (page execution period) Javax. servlet. jsp. JspWriter type
Exception A catch block on the JSP error page has benefited but not captured java. lang. any instance of Throwable is directed to the URI of errorPage. Note: exception is valid only when the page command has the attribute isErrorPage = "true; Page (page execution period) Java. lang. Throwable type
PageContext The PageContext class defines a forward method and two include methods to simplify and replace RequestDispatcher. the forward and include methods. This object provides the ability to query and modify attributes at all four levels of scopes. It also provides methods to forward requests to other resources and include other resources; Page (page execution period) Javax. servlet. jsp. PageContext (abstract class) Type

@ 1: The pageContext object can also be obtained and set session attributes in the same way as session. getAttribute () and session. setAttribute.

JSP four domain objects:

PageContext Request Session ServletContext
Page range Request range Session range Application Scope
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.