Home > Java > javaTutorial > body text

What are implicit objects in JSP? implicit object type

青灯夜游
Release: 2019-01-31 13:54:35
Original
4807 people have browsed it

The JSP container provides a list of objects that allow us to access various data in the web application; these objects are called implicit objects because they are automatically available in the script. The following article will take you to understand the implicit objects in JSP and understand the implicit objects commonly used in JSP. I hope it will be helpful to you.

What are implicit objects in JSP? implicit object type

#What is the implicit object in JSP?

Implicit objects in JSP are objects automatically created by the web container. The container makes them available to developers, and developers do not need to create them explicitly. Because these objects are automatically created by the container, they can be accessed using standard variables without explicit declaration; therefore, they are called implicit objects. [Tutorial recommendation: JSP video tutorial]

Types of implicit objects

JSP supports nine implicit objects , as shown below:

Request object

Every time the client requests a JSP page, the JSP engine creates a new object that represents the called request object. The request object is an instance of class javax.servlet.http.HttpServletRequest. The request object contains all information about the current HTTP request, as well as that client.

Note: The request object is only available within the scope of the current request. It is recreated every time a new request is made.

By using the request object's methods, you can access various data, such as HTTP headers, query strings, cookies...

Response object

JSP also creates a response object. Just as the server creates the request object, it also creates an object to represent the response to the client; that object is an instance of class javax.servlet.http.HttpServletResponse.

By using this object, you can add new cookies or date stamps, and change the MIME content type of the page. Additionally, the response object contains enough information about the HTTP to be able to return an HTTP status code or cause the page to redirect to another page.

Session object

The session object is used to track client-specific information between multiple requests. The session object is available on the server side, so it helps us preserve the state of the application between multiple requests. We can use session objects to store arbitrary information between client requests. A session object is an instance of class javax.servlet.http.HttpSession and behaves exactly like a session object under Java Servlets.

out object

The out object is an instance of class javax.servlet.jsp.JspWriter, which is used to send content in the response. The output stream is exposed through the out object to JSP.

The out object can refer to the output stream or the filter stream. We can send data to the output stream using out object methods, for example using the println() method, and JSP will take care of the rest.

pageContext object

The pageContext object is an instance of class javax.servlet.jsp.pagecontext, which represents the entire JSP page. Programmers can use the pageContext object to obtain the properties of the page.

Application Object

The application object is the representation of the JSP page through its life cycle; it is a direct wrapper of the ServletContext object of the generated Servlet, in fact Is an instance of javax.servlet.ServletContext object.

The application object is created when initializing a JSP page, deleting a JSP page using the jspdestroy() method, or recompiling a JSP page. As the name suggests, any object in the JSP page can access the application object's information.

Configuration (config) object

The configuration object is an instance of class javax.servlet.ServletConfig; it allows programmers to access the initialization parameters of the Servlet and JSP engines.

Page object

The page object is an instance of a JSP page, which can be considered as an object representing the entire JSP page. By using the page object, you can call any method of the page's servlet.

Exception Object

The exception object is a wrapper that contains the exception thrown from the previous JSP page. We can use exception objects to generate friendly error messages based on end-user error conditions.

The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of What are implicit objects in JSP? implicit object type. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
jsp
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!