This article mainly introduces the relevant information about the output stream at the end of the servlet in Ajax technology. It is very good and has reference value. Friends in need can refer to it
The server side of Ajax uses PrintWriter out= When resp.getWriter() responds to data, out.print(0) and out.print(1) are used to indicate success or failure, and there is a reason why out.write is not used. First, let’s take a look at the differences between print and write. Similarities and differences.
The common point is: both do not refresh the page, but only write data on the original page. In the end, they both rewrite the write method in the abstract class Writer.
The difference is: the print method Various types of data can be converted into strings for output. The overloaded write method can only output characters, character arrays, strings and other character-related data.
So it is not difficult to find the difference between the two above. In the setting callback function in the js code of the page, the value returned from the server is used to determine what to display. If the last value in the server-side servlet If the output is a number, and using writ, the number will not be converted into a string and output, which will lead to an incorrect judgment of the return value on the page.
The above is the output stream at the end of the servlet in Ajax technology introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for your support of the Script House website!
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Ajax realizes three-level cascading of provinces and municipalities
##Simple application based on Ajax form submission and background processing
Ajax simple implementation of uploading pictures and previewing
The above is the detailed content of About the output stream at the end of servlet in Ajax technology. For more information, please follow other related articles on the PHP Chinese website!