我将如何在JSP中立即提供反馈?
我有一个JSP表单,该表单(用户单击“提交”按钮时)实例化Java类并在其上调用方法。然后,此方法将请求(以专有格式)提交给在完全不同的框上运行的服务器。然后,该后端服务器要么向提交用户发送电子邮件,然后将“成功”返回到Java方法,要么返回错误消息。
一旦Java方法从另一个框上调用程序返回后,它将结果传递给JSP,该结果告诉用户可以期待电子邮件,或者显示其收到的错误消息。
问题在于,这需要时间才能实现。随着后端服务器的发展并变得更加复杂(现在必须调用在云服务器上运行的Web服务),该响应时间越来越长。
现在,由于没有立即反馈,我们有用户要么重新单击“提交”按钮,要么刷新。
有什么方法可以在JSP开始处理“提交”后立即给用户立即提供反馈?
I have a JSP form, that (when the user clicks the "submit" button) instantiates a Java class, and calls a method on it. This method then submits a request (in a proprietary format) to a server running on an entirely different box. That back-end server then either sends the submitting user an email, and returns "SUCCESS" to the Java method, or it returns an error message.
Once the Java method returns from calling the program on the other box, it passes the result to the JSP, which either tells the user to expect an email, or displays the error message it got.
The problem is that this takes time to happen. And as the back-end server has evolved, and become more complex (it now has to call a web service running on a cloud server), that response time has gotten longer.
And now we have users who, because there's no immediate feedback, are either re-clicking the submit button, or refreshing.
Is there a way I can give the user some kind of immediate feedback, as soon as the JSP begins to process the "submit," that will be sent before the whole chain of instantiation, method call, remote system call, and so forth begins?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己发现了一些足够好的:我可以执行“out.println()”,然后执行“out.flush”,这将立即提供反馈。快速而简单的测试证明了这一点。事实上,我还没有意识到它,这表明我对 JSP 知之甚少(尽管我会注意到它从未在我发现的第一个 JSP 教程中出现过,直到我查看了其他教程后才知道)我什至知道它的存在)。
但我欢迎更好的解决方案。
正如我始终欢迎建设性批评。
I found something on my own that will be good enough: I can do an "out.println()" followed by an "out.flush," and that will give immediate feedback. A quick-and-dirty test proves it out. And the fact that I wasn't already aware of it shows just how little I know about JSP (although I will note that it never came up in the first JSP tutorial I found, and it wasn't until I looked at other tutorials that I was even aware of its existence).
But I'd welcome a better solution.
Just as I always welcome constructive criticism.