Response.getwriter (). Write () differs from Out.print ()

Source: Internet
Author: User

1. First introduce the difference between the write () and print () methods:
(1), write (): Supports output character type data only, character, character array, string, etc.
(2), print (): The data of various types (including object) can be converted into bytes byte form by default encoding, which is output by the write (int c) method
2, introduce the difference between response.getwriter () and out:
(1), out and Response.getwriter classes are not the same, one is JspWriter, the other is java.io.PrintWriter.
(2), the principle of implementation is different: JspWriter is equivalent to a printwriter with a cache function, it does not directly output data to the page, but the data is flushed to the response buffer and then output,
Response.getwriter Direct output data (Response.print ()), so (Out.print) can only be output thereafter.
(3), out for the JSP built-in objects, refresh the JSP page, automatic initialization to get out the object, so the use of the Out object is needed to refresh the page,
The Response.getwriter () response information is output to a Web page through an Out object, and it is automatically closed when the response ends, regardless of the JSP page, without having to refresh the page
Image metaphor: When we call Response.getwriter () This object also obtains the brush of the Web page, then you can use this brush to draw anything you want to display on the Web page.
(4), the Out print () method, and the println () method generate IOException when the buffer overflows and there is no automatic refresh.
Both print and println of the Response.getwrite () method suppress IOException anomalies, and there is no IOException

Out.println (""); Method and page layout can not be wrapped, can only lead the HTML code wrapping, to achieve page layout wrap: Out.println ("</br>");

Response.getwriter (). Write () differs from Out.print ()

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.