0

我正在开发一个 Web 应用程序,其中我使用 Java 作为前端,使用 shell 脚本作为后端。我需要在 shell 脚本中处理很多文件,假设我需要在 shell 脚本中处理 1000 个文件。我正在使用 Java 中的以下代码

for(i from 1..1000)
{
       Call shell script to process file i
}

在 shell 脚本中,我正在做一些处理逻辑并将 o/p 存储在本地文件中(然后可以从 Java 访问)。

My requirement is, for everytime the shell script being called, an output is generated to a file. so as an when the control from shell script to java, I have to process it and display it in the front end. But the for loop should not break. It has to carry on with as it is but some front end work of displaying this file should also take place.

我尝试对此进行搜索,我得到的建议是为此使用 AJAX 和长轮询以及线程。你们能分享一些关于这个的想法吗?谢谢你。

4

1 回答 1

0

这也可以通过 websockets 来完成。例如,您可以将每 100 个中的每一个发回信息。也可以在 Google 上搜索“Comet”或“Reverse Ajax”(尤其是对于较旧的浏览器支持)。

确实,您可能想查看称为 Socket.Io 的东西或其他语言/环境的相应框架。

如今,很多用户都在运行支持 Web 套接字的 HTML 5 浏览器,因此根据用户的不同,您不必担心打开长轮询连接。

于 2012-07-24T03:14:05.100 回答