• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to show progress?

 
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of client is this - web app? Desktop app? Something else?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
What kind of client is this - web app? Desktop app? Something else?



webapp (Java Servlet)
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you considered an Ajax solution?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

Thanks & regards
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>>>>and have a place where the user can go in order to check the status

That's I need

Regards
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

    One way to show a progress bar is to program it in JavaScript (running in the browser), with AJAX (where the JavaScript is sending to and receiving requests from the server to check the status).
    [ October 18, 2008: Message edited by: Jesper Young ]
     
    Rancher
    Posts: 4803
    7
    Mac OS X VI Editor Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ignoring for a minute the topic of how you display that progress bar, think about this first:

    How do you know where you are in the progress?

    A lot of Microsoft packages show a nice progress bar that when it gets to the end, just goes back to the beginning. Sometimes many times.

    Do you want a progress as in real percent complete? or just some eyecandy to distract the user? The latter is a lot easier to do.

    With many actions on the server, you can't tell before hand how long it will take, so you can't provide any real progress information.

    Do you show the percentage of expected time to happen, based on an empty system? what happens when the system is slashdotted or on the front page of digg?
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic