views:

39

answers:

2

Consider, several users are using my Java Application. I am using Http Common Apache to GET/POST from a Http Server to get various user data.

There is a module in this client Application which triggers current Page no. of the Document (user1 opened). I want other Users(User2, User3,....UserN) to know the Page no. User1 opened.

Should all users listen/query the HTTP server in a time interval always ? I think it is not a good idea.

How can I implement this so that Load on server is minimized.

A: 

You need to use Comet (long-polling) in your server application to avoid periodic polling. J2EE 6 will support it. Developing with Comet and Java describes how to make it in J2EE 5.

Some other server-side platforms are not well suited for Comet (for example PHP).

Aleksey Otrubennikov
+2  A: 

Long Polling: Clients open a connection with your server and the server sends response only when user1 has changed the page (Considering your example). This will work great if the number of clients for your applications are not huge.

User Query: If dynamic update of page number on your application is not a hard requirement, querying the page number will be a good idea by providing a link would be a good option. This will improve the server performance.

Tushar Tarkas