• 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

Servlet reporting progress

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a apache tomcat servlet running on my webserver that does a bunch of work before reporting back to the jsp page at the client. I would like to add a progress bar so the user doesn't think the servlet is dead or not working. Is there a way to add code to my servlet that will report a progress bar to the JSP page displaying in the client browser?

Thanks a bunch.
M-
 
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
No. True progress bars are a complex affair with a client side component polling the server (usually via Ajax) which must have a means to obtain a percentage of completion from a long-running process, usually in a separate thread.

Most people simply punt and put up a "working" animation that doesn't show actual progress but gives the user something shiny to look at while the process is running.
 
Yile Ku
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. Okay I will go with the shiny 'im working' page.. how would that be done? I am a bit of a greenhorn to the JSP side.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brief outline:

(1) The first request starts a Thread which does the long-running process, then it returns a page which says "Working...".

(2) Each subsequent request checks the Thread. If it's still running then it returns "Working...".

(3) If the Thread has finished then the request returns something else, presumably the result of the long-running process.

The "Working..." page can be configured to auto-refresh every X seconds if you like.
 
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
Or, the page can issue the process as an Ajax request so that it can show the animation while the request is executing.

Note, most of this is JavaScript. JSP isn't going to be of much help except to create the markup.
 
Yile Ku
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the feedback. I am going to ask some newbie questions... so the jsp page is interpreted and executed on the server. The jsp page outputs text that is sent to the client and rendered in the client browser. My jsp page invokes some java servlet classes that execute on the server. So in order to do some kind of status, I need to have some code executing in the client browser querying the servlet as to its status. Also the code executing on the client needs to render the progress bar in the window meant for the output of the JSP page. The the code on the client needs to 'get out of the way' and let the servlet render the computation results. right?

M-
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic