views:

84

answers:

4

This may be a dumb question - and the title may need to be improved... I think my requirement is pretty simple: I want to send a request for data from a client to a server program, and the server (not the client) should respond with something like "Received your request - working on it". The client then does other work. Then when the server has obtained the data, it should send an asynchronous message (a popup?) saying "I've got your data; click on ... (presumably a URL) to obtain data". I have been assuming that the server could be written in Java and that client is html and JavaScript. I haven't been able to come up with a clean solution - help would be appreciated.

A: 

Most of the work invovles the server being asynchronous. To do this you must

  1. Have an ajax call to the server that starts a job and returns a confirmation the job has been started.
  2. A page on the server that will return whether or not any jobs are complete for a user.
  3. Have an ajax widget on your client side that pings that page on teh server every so often to see if any jobs have been completed. And if so make a pop up.

This is the only way unless you use Flex data services.

Zoidberg
A: 

Are you trying to do this on the HTTP protocol? It sounds like you're talking about a web application here, but it's not clear from the question. If so, then there are a variety of techniques for accomplishing this using AJAX which collectively go under the name "Comet". Depending on exactly what you're trying to accomplish, a number of different implementation, on both the client and server side, may be appropriate.

Thom Smith
A: 

for pure java i suggest something like jgroups (client+server are java) for html, you should use ajax - there you have a timer that checks every X seconds

Niko
A: 

To add to some of the other answers here, you can't do this with pure HTTP. This is because an HTTP response can only be sent as the result of an HTTP request. Therefore, the closest thing you could achieve in pure HTTP is for the client to poll the server with requests.

Matt Ball