Server Sent Events Using Server Side As Servlets
I have a running implementation of simple server sent events using servlets. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
Solution 1:
Response stream writes the content on the message body of http packet. As you are looping the integers so, all of them are getting added to the content one after the other. Unless flush/close is not closed on the stream you can keep writing on the stream and everything will by sent at once when you send the response.
Also some note about flush and close.You don't need to slufh,the servletcontainer will flush and close it for you. The close by the way already implicitly calls flush.Calling flush is usually only beneficial when you have multiple writers on the same stream and you want to switch of the writer (e.g. file with mixed binary/character data), or when you want to keep the stream pointer open for an uncertain time (e.g. a logfile).
Post a Comment for "Server Sent Events Using Server Side As Servlets"