Hi, I need to display text received from a serial device dynamically on a page. I wrote Java code that creates an event whenever one line of text is received. I am having difficulty in understanding how to implement a web-based listener that displays the lines on a page as they are received. Desired functionality is something like this: 1) Client browser is pointed to the server URL 2) User gets N lines of text and displays them 3) A text available event is received at the server ... My code goes here 4) The new line is shown on client's browser, i.e. it now shows N+1 lines 5) Another text available event is received... etc
I am new to servlets and web programming so any help will be much appreciated. Thanks, Cuney
Why can't we go for Observer pattern in this situation ?
It is a form of Observer. But HTTP connections have a limited time of life, and can't be initiated by the server. The Observable (on the server) can't push notifications to the Observer (the browser) if there isn't a connection at that time. This can only happen the next time the browser polls the server.
posted 10 years ago
Thanks Dittmer , that explains me a lot.
If you want something you never had do something which you had never done