I want to display a progress-bar in my Struts application. When a user clicks a buuton on a JSp page, some heavy background processing takes place and the results (a list of records) is displayed in the same window.I want to display a progress-bar while the list of records is being retrieved. I read an article on ONJava.com, which uses threads to achieve this. I am not too keen on using threads, though.
(HTTP request to /yourapp/JobServlet?action=startjob) 1. Start a background job (using threads, directly or indirectly) and assign it some kind of an identifier, say 1234 for example. 2. Render a HTML page for the client which includes a <META> tag for refreshing to URL /yourapp/JobServlet?action=poll&jobid=1234 after a few seconds or minutes, depending on the estimated duration of the job execution, and make the page say something like "processing your job, please wait..."
(HTTP request to /yourapp/JobServlet?action=poll&jobid=1234) 1. Look at a table of finished jobs. 2. If the job was marked as finished, render a "job complete" HTML page for the client. If the job was still in pending state, render another "please wait" page, effectively making the client wait for another X seconds or minutes. If you want a visual sign of progress, this "please wait" page should include a graphic that represents the progress.