Saturday, March 10, 2012

What is one way to allow users from a web page to start a long running server process but get an immediate res?

What is one way to allow users from a web page to start a long running server process but get an immediate response back? (assume a J2EE environment)What is one way to allow users from a web page to start a long running server process but get an immediate res?
Hi,



One way to archive this from web, is to make a multitasking/multi-thread process.



So you give the user an immediate response, but the process keep processing until it ends.



You can then:



1) As the user to refresh the page or do it automatically (javascript)

2) Query an AJAX webservice each time to see if the process is done.

3) tell the user the system will send them an email.



In the second thread that you opened when the user request or initiate the process in the server, when the second thead is done, you should:



- send the email to the user let them know it is finished.

- or, just use a boolean in your storage system (can be filesystem or database) to mark the process as finished. You麓ll probably need a way to identity the process against the user that trigger the request in the first place.



If you are using the webservice option, (or the page refresh) , check out for this boolean.



Happy Web Coding,What is one way to allow users from a web page to start a long running server process but get an immediate res?
If you mean some method of letting them know that the process has started and is running then a status bar control is t he best way to do that.

No comments:

Post a Comment