Reputation: 1487
So I need to develop a website where the users provide some data to the server (through HTML and JavaScipt) and then the data is processed on the server. The program which processes the data is most likely going to be a Java/C++ program (with heavy reliance on the availability of 3rd party libraries so the language of this program is not totally under my control). The program should execute on the server side since I expect it to be computationally intensive (it's solving optimization problems based on some data provided by the user(s)). After the program finishes processing, the results are returned to the user and are displayed nicely in HTML.
I'm not entirely sure on how to communicate between the client and server. I've been looking into CGI (Common Gateway Interface) but from my readings it seems like it's outdated these days? Is there any better alternative to CGI? I read that CGI might be slow these days, and I need an approach which will provide fast enough processing times.
Upvotes: 0
Views: 999
Reputation: 8338
CGI is the Crusty Granddaddy of the Internet (really true). It is from a time when multi-threading wasn't considered and computers came with 8Mb of memory. You really should not use it.
There are plenty of alternatives. Take a read on Servlets. They allow for so many wonderful things.
Now, what you must consider is this: will the user be happy to wait for a response in the browser, or would you prefer the user being able to do something else, and tell the user when the processing was done?
If the user cannot do anything while the server is processing AND there are no timeouts on the connection then you can opt for a simple HTTP POST or GET and move on to more challenging fields.
If you want the user being able to do other things and then be notified when the process is done, then you have 2 choices:
Use something like jQuery / ajax (https://api.jquery.com/category/ajax/)
OR
Allow the user to navigate through your site. For every page the user request, also check if the result is ready. If the result is ready, then display it to the user. Otherwise, mum is the word. You could even do something fancy as displaying how much time is still required, or how many steps are still to come, along with a chance for the user to cancel the process.
I would go with jQuery, but that is my personal choice.
Upvotes: 1