"Streaming" text from a servlet to an applet without polling
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Eoin_McGee
Posted On:   Monday, January 12, 2004 08:50 AM

Hi All, I am trying to write a servlet based web application that will effectively pass an ever changing text string from a web server to an applet client without the need for the client to continuously poll the server to receive each update. Unfortunately, despite much research, time and effort I am starting to believe that the task may be impossible. The key factor is that I don't want the client to poll the server to get every update as in the final production environment, when using SSL encryption and certificates, the performance overhead of each request is unacceptable. What I have tried to do is to have the applet client call the servlet using URLConnection , then in the Service methods    More>>

Hi All,


I am trying to write a servlet based web application that will effectively pass an ever changing text string from a web server to an applet client without the need for the client to continuously poll the server to receive each update. Unfortunately, despite much research, time and effort I am starting to believe that the task may be impossible.


The key factor is that I don't want the client to poll the server to get every update as in the final production environment, when using SSL encryption and certificates, the performance overhead of each request is unacceptable.


What I have tried to do is to have the applet client call the servlet using URLConnection , then in the Service methods on the servlet (either doPost or doGet) I block and loop, writing the changed text string to a PrintWriter generated from the HttpServletResponse object. What I am seeing is that the client does not receive any data back until the doGet or doPost methods finish completely. When this happens, the client gets all the previously written data in one go. I have tried both the PrintWriter.flush() and HttpServletResponse.flushBuffer() methods in-between writes but this makes no difference.



Does anyone have any suggestions or is it just impossible to try and misuse the Request/Response HTTP protocol in such a way.



Any help you can give is much appreciated.


Eoin.


p.s. When I use the HttpServletResponse.setContentLength() method to set the content length header of the response to be that of the text String then the client does receive the data before the doGet or doPost methods finish but I am not then able to pass any more text Strings back to the client.

   <<Less

Re: "Streaming" text from a servlet to an applet without polling

Posted By:   Jerry_Lampi  
Posted On:   Monday, January 12, 2004 02:16 PM

No help here, just encouraging you to post a solution should you find one other than jGuru. We have the same problem.



Another unfortunate side effect of polling (other than performance) is that the server creates a new connection for each poll which results in a TimeWait (or is it CloseWait) to be forced on the server. Each wait requires two minutes to free (at least on certain servers we've tested under) -- many otherwise usable connections get tied up for no good reason.
About | Sitemap | Contact