Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of servlet end output Stream in Ajax Technology

Shulou Source: shulou.com Published: 2022-06-03 14:34:30 11月12日 Update

This article mainly introduces the example analysis of the output stream at the end of servlet in Ajax technology, which is very detailed and has a certain reference value. Interested friends must read it!

When the server side of Ajax responds to data with PrintWriter out=resp.getWriter (), out.print (0) and out.print (1) indicate success or failure instead of out.write for a reason. First, let's take a look at the similarities and differences between print and write.

What they have in common is that neither of them refreshes the page, but only writes data on the original page. In the end, the write method in the abstract class Writer is rewritten.

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

So it is not difficult to find the difference between the two above, in the js code of the page, the callback function is based on the value returned from the server to determine what should be displayed, if the last output in the server-side servlet is the number, and if writ is used, then the number will not be converted into a string output, resulting in an incorrect judgment of the return value on the page.

The above is all the content of the article "sample Analysis of the end output Stream of servlet in Ajax Technology". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Output character data page string method server service technology end example analysis content form number article success above no code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL Microsoft Linux Shulou Technology