Link to home
Start Free TrialLog in
Avatar of prain
prainFlag for United States of America

asked on

How to install a progress bar on a Servlet

Here is the scenario.

I have a servlet. This servlet produces the presentation GUI interface that runs on a browser.
This interface contains several inputs where the user is allowed to input some data. At the
click of a button, from my servlet, I call a java class that does some (bit time consuming)
process. What I want is, while the processing is being done by the behind teh scene java class,
I want to show the user a progress bar or something similar, so that the user would know something
is going on. How would I do this?.

-prain
Avatar of radarsh
radarsh

Hi prain,

There are two ways to do this.

First
=====
This is a dummy progress bar and will not show a realistic status of the event
happening on the background. What you do is, display an animated gif on the page
until the response is returned from the servlet.

Second
======
This is bit difficult to code and is highly realistic. In this approach,
you use AJAX to periodically check the status of the background process.
You can have some status area on the servlet which will be updated by the
background process. The AJAX hit checks this status and reports on the UI.
AJAX being asynchronous, the page won't be refreshed/reloaded. The server
hit happens in the background.

If that's not clear, do ask.

________
radarsh
Avatar of prain

ASKER

Thanks radash. AJAX is a separate piece of SW right?. If I have Tomcat, should I have AJAX too?
Please enlighten me.
Hi,

>>"If I have Tomcat, should I have AJAX too?"
No. There is AJAX DWR which you can easily integrate with your Java app.

http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example/
That is the best example on how to use AJAX for progress bar. I think that it combines with Jakarta Common Upload.

David
DWR is a very simple and easy to use AJAX framework, as David said.
You can go ahead with that.

http://getahead.ltd.uk/dwr/

________
radarsh
Avatar of prain

ASKER

hello all,
Thanks for your inputs. I have talked to the admin here with regard to get the AJAX. It may take some time. The environment here is not that easy to get work done. You know govt?. So I am, in the mean time looking around to get this done without using AJAX or similar, but by using pure java and servlets.

Please let me know if you have any other avenues.

Thanks
prain
ASKER CERTIFIED SOLUTION
Avatar of Isisagate
Isisagate

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
forgot to add <script type="text/javascript" language="javascript"></script> around the guts.