JSP detailed article--out

Source: Internet
Author: User

OutObject

The Out object is used to output information on a web Browser and to manage the output buffers on the application server. When you use an out object to output data, you can manipulate the data buffers to clear the remaining data in the buffer and make buffer space for other outputs. When the data output is complete, close the output stream in a timely manner.

1.outputting data to the client

An out object can output data of various data types, which are automatically converted to strings when the output is non-string. out provides print () and println () Two kinds of output information to the page.

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 newline character is more than the print () method.

When you use the println () method to output to a page, you cannot really see the effect of text wrapping. If you want to see the effect of a newline, include the contents of the output in HTML tags <pre> .

2. Manage the appropriate buffers

an Out object is a more important feature of managing the contents of a buffer.

The Clear () method of the Out object clears the contents of the buffer, similar to resetting the response stream, and generates a IOException exception if the response has already been committed .

The Clearbuffer () method of the Out object is used to clear the contents of the current buffer and can be accessed even if the content has been submitted to the client.

methods for managing buffers for out objects

Clear (): clears the contents of the buffer

Clearbuffer (): clears the contents of the current buffer

Flush (): Refresh Stream

Isautoflush (): detects whether the current buffer is full when it is automatically emptied or throws an exception

GetBufferSize (): Gets the size of the buffer




JSP detailed article--out

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.