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 bufferThe 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