开发者

Ajax request during a file upload takes a long time to complete

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 t开发者_如何学JAVAo 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜