Get servlet request status before response is answered

Good evening,

I am working on writing a Java Servlet (Struts 2, Tomcat, JSP, etc.) that is capable of performing fairly complex simulations. It may take up to 2 minutes to complete and return a graph of results. It is trivial to calculate the percentage of simulations performed, because the process works by repeating the same calculations 1000 times.

I would be interested to know if anyone ever tried to use client-side technology to provide any percentage estimate. I. Request servlet processing to get the number of loops executed at different points during the simulation. This could then be displayed as a panel in a client browser.

Any thoughts, advice, resources will be highly appreciated.

Thank,

Alex

+3
source share
4 answers

Your database has a table to support the list of simulations along with their server-predicted progress.

In your web application, use AJAX to query the server every few seconds (1-20 depending on the load - this is what I would go with) and update the graphical progress bar. Most javascript libraries have simple timer-based AJAX functions to do just that.

There are several details to find out, for example, whether or not completed simulations remain in the database (registration information may be useful), but in general this should be quite simple.

+4
source

mime/multipart , .

Bugzilla , "..." - , .

+4

Struts2, ExecuteAndWait Interceptor. p >

refresh-with-timeout. , , AJAX, ( ).

Struts2 ( ) ( ) wait, . jsp, - "wait..." , , () . , jsp , getProgress(), .

+2

AJAX - .

0

Source: https://habr.com/ru/post/1750003/


All Articles