About the output stream at the end of the servlet in Ajax technology, ajax output stream

Source: Internet
Author: User

About the output stream at the end of the servlet in Ajax technology, ajax output stream

The Ajax server uses PrintWriter out = resp. when getWriter () is used to respond to data. print (0), out. print (1) indicates success or failure, instead of out. there is a reason for writing. First, let's take a look at the similarities and differences between print and write.

In common: both of them do not flat New pages, but only write data on the original pages. In the end, they all overwrite the write method in the abstract class Writer.

The difference is that the print method can convert various types of data into strings for output. The reload write method can only output character-related data, such as characters, character arrays, and strings.

Therefore, from the difference between the two above, it is not difficult to find that in the setting callback function in the js Code on the page, it is determined by the value returned by the server, if the number is output at the end of the servlet on the server, and writ is used, the number will not be converted into a string for output, resulting in incorrect judgment on the returned value on the page.

The above is the output stream at the end of servlet in the Ajax technology introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!

Related Article

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.