Streaming text from servlet to applet

E

Eoin

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 any 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top