JSP operation principle and nine large implicit object Description _jsp programming

Source: Internet
Author: User

When each JSP page is accessed for the first time, the Web container handles the request to the JSP engine (that is, a Java program). The JSP engine first translates the JSP into a _jspservlet (essentially a servlet), and then invokes it as a servlet call.

Because the JSP will be translated into a servlet on the first visit, the first visit is usually slower, but the second visit, the JSP engine if it finds that the JSP has not changed, it will no longer translate, but directly call, so the execution efficiency of the program will not be affected.

When the JSP engine calls the JSP's corresponding _jspservlet, it passes or creates 9 Web development-related objects for _jspservlet to use. JSP technology designers to facilitate developers when writing JSP pages to obtain these Web object references, deliberately defined 9 corresponding variables, developers in the JSP page through these variables can quickly get the 9 large object references.

These 9 objects are respectively which, as well as the function is also the written examination frequently examines the knowledge point.

JSP nine-Large implicit object

Request//representative of the Request object

Response//Representative Response Object

Config//Representative ServletConfig Object

application//Representative ServletContext Object

exception

Session

Page

Out//Represents Response.getwriter (), character output stream object

PageContext

PageContext objects

PageContext object is the most important object in JSP technology, it represents the running environment of JSP page.

This object encapsulates not only references to the other 8 large implicit objects,

It itself is also a domain object that can be used to save data.

Also, this object encapsulates some common operations that are often involved in web development, such as introducing and jumping other resources, retrieving properties from other domain objects, and so on.

Get other objects through PageContext

GetException method returns exception implicit object

GetPage method returns the page implicit object

Getrequest method returns the request implicit object

GetResponse method returns response implicit object

The Getservletconfig method returns the config-implicit object

Getservletcontext method returns application implicit object

The GetSession method returns the session-implicit object

The Getout method returns an out implicit object

PageContext encapsulates the meaning of the other 8 large built-in objects, thinking: If the PageContext object is passed to a normal Java object during the programming process, what functionality does the Java object have?

PageContext as a domain object

Methods of PageContext objects

public void setattribute (java.lang.String name,java.lang.object value)

Public Java.lang.Object getattribute (java.lang.String name)

public void RemoveAttribute (java.lang.String name)

The PageContext object also encapsulates ways to access other domains

Public Java.lang.Object getattribute (java.lang.String name,int scope)

public void setattribute (java.lang.String name, Java.lang.Object value,int scope)

public void RemoveAttribute (java.lang.String name,int scope)

Constants that represent individual fields

Pagecontext.application_scope

Pagecontext.session_scope

Pagecontext.request_scope

Pagecontext.page_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.