This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a apache tomcatservlet 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?
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.
Or, the page can issue the process as an Ajax request so that it can show the animation while the request is executing.
Joined: Jan 27, 2011
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?