1. first introduce the differences between the write () and print () methods:
(1), write (): only supports output of character type data, character, character array, String, etc.
(2) print (): Data of various types (including objects) can be converted to bytes by default encoding. These bytes are output through the write (INT c) method.
2. Introduce the differences between response. getwriter () and out:
(1) The out and response. getwriter classes are different. One is jspwriter and the other is Java. Io. printwriter.
(2) Different execution principles: jspwriter is equivalent to a printwriter with the cache function. Instead of directly outputting data to the page, it refreshes the data to the Response Buffer and then outputs the data,
Response. getwriter directly outputs data (response. Print (), so (Out. Print) can only be output after it.
(3) The out object is a built-in JSP object. Refresh the JSP page and obtain the out object automatically after initialization. Therefore, you need to refresh the page when using the out object,
The response information of response. getwriter () is output to the webpage through the out object. When the response ends, it is automatically disabled and is irrelevant to the JSP page. You do not need to refresh the page.
Image metaphor: When we call the response. getwriter () object to get the paint brush for the web page, you can use this paint brush to draw anything you want to display on the web page.
(4) The print () method of out and the println () method will generate an ioexception when the buffer overflow is not automatically refreshed,
The print and println of the response. getwrite () method both suppress the ioexception and do not have ioexception.
Out. println (""); the method cannot wrap the page layout. It can only wrap the HTML code. to wrap the page layout, you can: Out. println ("</BR> ");
Article Reprinted from: http://blog.csdn.net/javaloveiphone/article/details/8133772
Difference between response. getwriter (). Write () and out. Print ()