文件上传期间的 Ajax 请求需要很长时间才能完成

发布于 2024-08-19 06:57:00 字数 534 浏览 4 评论 0原文

我正在使用 Webphere 服务器。我正在使用 Apache FileUpload 方法通过 servlet 执行文件上传。

我将一个侦听器附加到此 FileUpload,该侦听器更新“百分比”字段,表示已处理请求的百分比。请求被定向到 iframe(表单的目标是 iframe),以便触发请求的页面不必等待响应完成,因此不会只向用户显示空白页面。我还将对会话的进度侦听器的引用添加到会话中。

一旦我在 JSP 页面上触发表单上的提交,1 秒后,然后每隔一秒,我都会触发一个 ajax 请求,该请求会发送到一个 servlet,该 servlet 会查找 ProgressListener 并使用百分比字段进行响应。该过程工作正常,但在 Websphere 上,有时此 Ajax 请求可能需要长达 30 秒才能完成!我在一个简单的 Tomcat 服务器上测试了同样的事情,请求/响应在一秒钟内就出来了。

可能出什么问题了?是服务器设置吗?

谢谢,

编辑:一旦发出请求,servlet 内从会话获取百分比的代码就会运行。瓶颈似乎在于将请求传递回客户端浏览器。

I'm using a Webphere server. I am performing a file upload through a servlet using the Apache FileUpload methods.

I attach a listener to this FileUpload which updates a "percentage" field denoting what percentage of the request has been processed. The request gets directed to an iframe (form's target is an iframe) so that the page that fired the request doesn't have to wait for the response to complete and therefore it won't show the user just a blank page. I add a reference to the progress listener to the session as well.

From the JSP page as soon as I fire the submit on the form, after 1 second and then every second I fire an ajax request which goes to a servlet which looks up the ProgressListener and responds with the percentage field. The process works fine, but on Websphere sometimes this Ajax request can take up to 30 seconds to complete! I tested the same thing on a simple Tomcat server and there the request/response comes out within a second.

What could be wrong? Is it a server setting?

Thank you,

Edit: The code inside the servlet that gets the percentage from the session runs as soon as the request is made. The bottleneck seems to be in delivering the request back to the client browser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜无邪 2024-08-26 06:57:00

你是否配置了websphere来编译和缓存jsp页面,或者每次都重新编译?

您可能想要使用 AOP(AspectJ 或 Spring)或分析器来查看 ajax 调用发生了什么,以便您可以在不更改 jsp 页面中的任何代码的情况下进行监控。

分析器可能是一个更好的起点,这样您就可以全局查看正在发生的情况,然后使用方面以细粒度的方式进行监控并确定瓶颈在哪里。

您还可以查看预编译 jsp 页面是否有帮助。本教程应该有用:
http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.samples.doc/tutorial/tdedeployjsp.htm

Do you have websphere configured to compile and cache the jsp page, or is it recompiling each time?

You may want to use AOP, either AspectJ or Spring, or a profiler, to see what is going on with the ajax call, so that you can monitor without changing any code in the jsp page.

The profiler may be a better starting point, just so you can look globally at what is going on, then use aspects to monitor in a fine-grained fashion and decide where the bottleneck is.

You could also see if precompiling the jsp pages will help. This tutorial should be useful:
http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.samples.doc/tutorial/tdedeployjsp.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文