JSP details -- out

Source: Internet
Author: User

JSP details -- out
Out object

The out object is used to output information on the web browser and manage the output buffer on the application server. When using the output data of the out object, you can operate on the data buffer to clear the residual data in the buffer in time and make the buffer space available for other outputs. After the data output is complete, close the output stream in time.

1. Output data to the client

An out object can output data of various data types. When a non-string is output, it is automatically converted to a string. Out provides two types of output information to the page: print () and println.

Print () method

Using the print () method to output information to the client is equivalent to using a JSP expression.

Example:

<%

Out. print ("zhangsan ");

%>

<%

= "Zhansan ";

%>

Println () method

A line break is more than the print () method.

When you use the println () method to output data to a page, you cannot really see the effect of text line breaks. If you want to see the effect of line breaks, you must use HTML tags to output the content.

Include.

2. Manage the corresponding buffer

The buffer content is managed as an important function of the out object.

The clear () method of the out object can clear the content of the buffer, similar to Resetting the response stream. If the response has been submitted, an IOException occurs.

The clearBuffer () method of the out object is used to clear the content of the current buffer, and can access this method even if the content has been submitted to the client.

Out Object Management Buffer Method

Clear (): clear the buffer content

ClearBuffer (): clears the content in the current buffer.

Flush (): refresh the stream

IsAutoFlush (): checks whether the current buffer is automatically cleared or throws an exception when it is full.

GetBufferSize (): Get the buffer size




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.