Push values from web server to client every 20ms (Java MVC)
I am new to Java. I am trying to write something on lines of MVC where my web server has a java method that reads a text file one row at a time every 20 milliseconds and I want to send (/push) this value to client every 20 milliseconds (that is at the same instant as the new row is read from CSV). I have read this http://en.wikipedia.org/wiki/Comet_%28programming%29 But being very new to all this could not understand much. How push/pull/streaming works and what to use here. Moreover if I should be pulling or pushing values here. I think I should push else server will be clogged by so many pull requests every 20ms. Please suggest. Any piece of code will be a great great help.
You cannot push data from Web server to client/browser as client machines firewall will block any kind of connection you try to make with machine. Browser has always need to pull it from server.
Please refer to following link for the example
Push would seem to be the best answer here, though you may have some issues getting everything to work on a 20ms round-trip without falling behind, unless this is all going to work on a local network.
The currently-emerging state of the art for push seems to be HTML5 WebSockets. If you can ensure use of the latest web browsers that have support for it, I would suggest going with that.
Here is an example of building a simple WebSocket app.