How to clear the screen output of Java httpservletresponse

I'm using servletresponse getWriter(). Write (string) writes to the browser window

But how do I clear text previously written by other similar write calls?

Solution

The short answer is, you can't - once the browser receives a response, there's no way to retract it (unless there is some way to stop the HTTP response abnormally to make the client reload the page, or something to some extent.)

In a sense, the last place where a response can be "cleared" is using servletresponse Reset method, which will reset the buffer of servlet response according to servlet specification

However, this method also seems to have a problem, because it is only effective when the buffer has not been submitted (i.e. sent to the client) through the flush method of ServletOutputStream

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>