when this code works nothing shows the progress and page remains as it is for a long time. I have given the form target a mini frame right bottom of the page to output when finish. There is no error in the code.
Can you please let me know how can I show the progress of the sent mails as this code is sending more than 20K emails
I want to show the number of emails sent
thanks & best regards
[ October 18, 2008: Message edited by: Farakh khan ]
Originally posted by Bear Bibeault: Have you considered an Ajax solution?
I want solution in Java as well in the way that it should show the progress of sending mails that how many emails sent and this figure should change with each loop but when it show the next figure previous should be deleted
Thanks & regards
Joined: Mar 22, 2005
Being a web app, it won't be completely in Java - some client-side code (or at least HTML) will be involved. AJAX can help avoid having to reload the web page that shows the current status. It's at least something to consider.
You'll also need a servlet that can return the current status to the client. So you need to think about how to keep the status in a place where that servlet can access it, maybe as an attribute in the web app context. [ October 18, 2008: Message edited by: Ulf Dittmer ]
For a pure Servlet/JSP solution, you'd need to refresh the page continuously, updating the progress display each time.
The processing would need to be spun off into its own thread (or performed in a separate daemon program) so that the Servlet thread could continue and return information while the processing goes on.
Joined: Mar 22, 2008
Originally posted by Bear Bibeault: The processing would need to be spun off into its own thread (or performed in a separate daemon program) so that the Servlet thread could continue and return information while the processing goes on.
Can you please elaborate more the above point? Please in easy language as my English is weak
In order for the long process to be independent from the display (and therefor not block the response), it either must be in its own thread, or in another program completely.
Personally, I'd not use a progress bar at all. I'd just let the long process proceed in the background and have a place where the user can go in order to check the status. That way, they are not just sitting there watching a progress bar complete, but can be doing other things.
Ben Souther has a "Long Running Process" example on this page.
Joined: Mar 22, 2008
>>>>>and have a place where the user can go in order to check the status
Seeing this question and your other question, I think that you don't understand how the HTTP request-response cycle works with regard to servlets.
It works like this:
User enters an URL in the browser. Browser sends an HTTP request to the server.
The app server (Tomcat for example) calls your servlet to handle the request.
The doGet() method in your servlet generates an HTML page and returns.
The app server sends the generated page back to the browser in an HTTP response.
The browser on the user's computer displays the HTML page.
Note that generating the page by the servlet and rendering the page in the browser are two separate steps, that happen one after the other. So, the browser is not rendering the page while the code in your servlet runs - that happens after the servlet has finished.
If your servlet sends e-mails, then the resulting HTML page which shows the status is not sent back before the servlet is done with all the e-mails. You can't show the progress by making the servlet print something to the output, because the output won't be sent back to the browser before the servlet is done.