JSP implicit object (1)

Source: Internet
Author: User

JSP implicit object (1)
1. Initial appearance of JSP implicit objects;

(1) There will always be nine hidden objects during the interview, which will be described in detail below;

(2) In JSP pages, information such as request requests and response responses are often processed. to simplify the program design, JSP defines nine commonly used implicit objects (implicit objects ),

These hidden objects do not need to be created with the new keyword on the JSP page, but are created and managed by the Servlet container and passed to the Servlet implementation class on the JSP page for use. (For example)


(3) In the _ jspService () method of the Servlet implementation class on the JSP page, the code segment for automatically initializing the JSP implicit object is as follows:


The jspService () method is internally defined. Therefore, you can use them on the jsp page <%> or <% = %>!

II. out implicit object; (1) out object output information mainly includes print (), println () and newline (). (2) buffer-related methods: there are several methods related to the output buffer in the out object:

1. flush () method

Flush () is used to refresh the stream. In Java, I/O operations are converted into stream operations. Out. the write () output information is temporarily stored in the stream object buffer. The refresh operation transmits the information in the buffer to the target object for processing. If the target object is a second or byte stream, refresh it, So calling the flush () method will refresh the buffer in all output stream object chains. If the buffer zone is full, this method is automatically called to output information in the buffer zone.

If the stream has been closed, calling print () or flush () will cause an IOException;

2. clear () method
Clear () indicates clearing information in the buffer. If the buffer is empty, executing this method will cause an IOException.
3. clearBuffer ()
ClearBuffer () is similar to clear (). It clears the output buffer and returns the result. Unlike clear (), clearBuffer does not throw an exception.

4. getBufferSize ()
GetBufferSize () returns the size of the output buffer, in bytes. If there is no buffer, 0 is returned.
5. getRemaining ()
GetRemaining () returns the remaining idle space in the buffer, in bytes.

6. isAutoFlush ()
IsAutoFlush () returns a real value to indicate whether the buffer is automatically refreshed.


3. request implicit object; see article: http://blog.csdn.net/xlgen157387/article/details/39136725

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.