This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to Show the ProgressBar in the browser when i am doing Complex Operation on server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to Show the ProgressBar in the browser when i am doing Complex Operation on server " Watch "How to Show the ProgressBar in the browser when i am doing Complex Operation on server " New topic
Author

How to Show the ProgressBar in the browser when i am doing Complex Operation on server

ramakrishna rayudu
Ranch Hand

Joined: Mar 08, 2011
Posts: 57
Hi,,

In our project from structs (MVC ) Action classes we are calling EJB Beans for Business Logic purpose.
here the problem is our database is MySql it has lot of data all data we need as per the client requirement.
when the user Login in to the Application it is taking a lot of time with out showing the ProgressBar or any thing.
how this can be done means i need to get the information from MySql DataBase and i need to Show the Progressbar in the Browser when the Query is executing.
main thing is with out using AJAX Call
can you please give me any Idea........

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Why no Ajax? It's the right way to do it.

In the absence of Ajax (which makes no sense to me), I'd probably think of using an iframe. But that's a really klunky way to go about it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ramakrishna rayudu
Ranch Hand

Joined: Mar 08, 2011
Posts: 57
okey...how we need to do with AJAX......
normally what we are doing is when ever user click on the Login Button we are keeping a blocking image on HTML page
and we are submitting the from when the response arrived from server automatically that blocking image will gone.

now i want to make show progressbar with complete Information how much time should user need to wait in terms for progress bar completion....

am i need to use any Threading Concepts on ServerSide ??


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Submit the complex operation as an Ajax request. While it is executing, you can send other periodic Ajax requests to find out what percentage of the operation is complete. Use that value to update the appearance of the progress control.

I highly suggest using a JavaScript library such as jQuery to do your Ajax. jQuery UI also has a progress bar widget you can use rather than build your own.
ramakrishna rayudu
Ranch Hand

Joined: Mar 08, 2011
Posts: 57
am i need to use any Threading Concepts on ServerSide ??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Not necessarily. The servlet container handles most threading for you. Being able to have multiple requests in multiple threads be able to keep track of each other could be tricky. Can you tell us something about the complex operation that you are trying to track?
ramakrishna rayudu
Ranch Hand

Joined: Mar 08, 2011
Posts: 57
it means i need to get the Data from DataBase it has a lot of data and i need to call the some shot of webservices for User Validations and all...
ramakrishna rayudu
Ranch Hand

Joined: Mar 08, 2011
Posts: 57
i am not asking about the multiple Requests in that case the server will create Threads and manage.
but in this case i am thinking
i need to start the thread it will Executing QUERY and calling the web services
at the same same time from my servlet i will redirect to Progreassbar page.
so each and every i will make ajax call and from that ajax call i need to get status of the Operation on the Server Side Thread.
i will update According to that....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

No, you can't redirect in the middle of the operation. You'd either need to spawn it off as its own thread, or use Ajax as I suggested and let the servelt container handle the threading for you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Show the ProgressBar in the browser when i am doing Complex Operation on server