Here’s the problem:
I’d like to expose a page within a site which is able to report some log lines.
The site is a java spring 3.0 web application.
Theoretically there are two ways to get the job done:
1- the server pushes the lines to be logged whenever they are ready.
2- the client does a polling for new lines.
I’d prefer the first way but I really don’t know if it is feasible or not.
I imagine the scenario as follows:
- the client REQUESTs the “consolle page”
- the server RESPONSEs such page
END TRANSACTION - the server REQUESTs (or what?) the updates…
- the client… ?
And finally, what techonolgy suits best my requirements? I suppose JSP are not enough maybe some javascript?
I’ve implemented similar things in the past using timed polling with AJAX.
Your console page would run some javascript/jQuery that polls the server every so often via an AJAX request, and if it receives new data, appends (or prepends, whichever you like) it to your console box, or div, or whatever it is you’re using.
Last I checked (which was quite a while back), this is how Facebook chat worked (though it’s probably changed since then).
There are push implementations you could use (check out HTML5 Websockets, that might help), but AJAX polling is probably the simplest solution for something like this.