Synchronising Data and Encrypting Transmission

Offline applications, like job lists or meter-reading applications, will need to synchronise data with the back-end database, notifying it when jobs are completed.
The user will also need to query the database for new jobs.

AJAX is the best way to do this, using the XMLHttpRequest object from JavaScript. You can use the GET action to query the back end for new jobs and the POST action to update jobs from your app.
On the server side you will need a Servlet to respond to these calls from the PDA and to return JSON or XML data. The URLs you use for querying and updating the database will only work when you are online, so you need to add them to the network section of the HTML5 manifest file:




Although the "A" in AJAX stands for Asynchronous, you may find it best to use synchronous calls for two reasons:

If you want to keep the feel of asynchronous calls (so the browser UI does not lock up), but need to order the updates, you can try chaining the asynchronous requests.
Make a normal asynchronous call to send the first update, and in the callback method for this call, get a new XMLHttpRequest object and make another asynchronous call. You can continue chaining each new request from the callback of the previous request until all your updates have been sent, then do a call to get the new jobs down.

Also note that you may have logged into the app when offline, then synch when you have a network connection. The server will not have an authenticated session with the PDA at this point, so you will need to "roll your own" security. You can send the username and password from the app with each AJAX call and your Servlet can then authenticate each request.

To keep the data safe in transit, you will need to encrypt it. The easiest way to do this is to use https instead of http.