Hi guys, thanks for your suggestions...... xpages as servlet
responding with data in any format is what xagent does.
I am not smart
enough to comprehend things like
applicationscope variables is maintained by servlet container, dont know what kind of relationship it has with server task.
and Looks like ServletContextListener and prenty more others
http://www.examulator.com/moodle/mod/resource/view.php?id=460 are what I am after, an direct hit here