The difference between response.getwriter () and out objects in a JSP

Source: Internet
Author: User

Response.getwriter (). Append (string content)---output a string to a page
The type of the Out object is JspWriter, and Response.getwriter () is a printwriter, and the Out object can also be obtained by Pagecontext.getout (), and the two objects are of different types

Out.print (null); Throws an exception, printwriter.print (NULL) does not throw an exception

JspWriter is an abstract class, and PrintWriter is an ordinary class that inherits writer.

The Getwriter () method can output a string of characters on the page, and out is also an output object, the difference being that the result of the Getwriter () method, always takes precedence over the Out object, can use the Out.flush () method to force the contents of the property buffer, Outputs the output of an Out object first

Causes of this phenomenon:
The Out object is actually dependent on the printwriter, he needs to save the output to the response buffer, and then wait for the JSP page out to meet certain conditions before the output method will be called to output the content directly to the page

And printwriter can be directly output.

The difference between response.getwriter () and out objects in a JSP

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.