| Author |
Showing the status of an operation
|
sreenath reddy
Ranch Hand
Joined: Sep 21, 2003
Posts: 415
|
|
Hi I have a scenario where i click a button from a jsp which results in DB operation(This method is called from my servlet) and this operation may take some time.In this situation i wont be able to show the user about the status of the operation.(Now whats happening is the user wont be shown anything till the operation is complete) Now what i need is ,i want to show the user a page showing that the operation is in progress and as soon as the operation is complete i need to show the proper page How can i achieve this ??
|
 |
Ajith Anand
Ranch Hand
Joined: Aug 30, 2004
Posts: 40
|
|
1. Using one of the sql query tools collect an average time-for-retrieval per record metric. 2. Before executing the proper query execute select count(*) from XXXXX where query ; 3. Divide count(*) by the average obtained from point 1 to get the total time. Create a jsp page with a directive <meta http-equiv="refresh" content="<%= totaltime>"> and configure a javascript progress bar..... The advantage of this approach is that, it would cut-short the server round-trips, which would be required otherwise if we engage to show a realtime status.
|
LXI Technologies P Ltd
[url]www.lxisoft.com[/url]
|
 |
Chandrashekhar Tupe
Greenhorn
Joined: Aug 11, 2004
Posts: 1
|
|
Originally posted by sreenath reddy: Hi I have a scenario where i click a button from a jsp which results in DB operation(This method is called from my servlet) and this operation may take some time.In this situation i wont be able to show the user about the status of the operation.(Now whats happening is the user wont be shown anything till the operation is complete) Now what i need is ,i want to show the user a page showing that the operation is in progress and as soon as the operation is complete i need to show the proper page How can i achieve this ??
You can achieve his by running your logic of performing DB operations in a thread. Spawn a thread in servlet and return back to jsp showing status as processing and keep updating the status in thread. I hope it suffices your requirements.
|
 |
sreenath reddy
Ranch Hand
Joined: Sep 21, 2003
Posts: 415
|
|
Hi Can u just paste some piece of code but however that jsp should be refreshed at regular intervals right .......which mean i need to communicate with the servlet too ....
|
 |
Atul Prabhu
Ranch Hand
Joined: Dec 17, 2002
Posts: 60
|
|
Hi, You can use the logic given below : out.println("Processing .........."); out.flush(); { DB related code or processing code u want to perform } out.println("<SCRIPT>"); out.println("document.location.href='otherpage.jsp'"); out.println("</SCRIPT>"); Try it out. out.flush() would flush the contents to the output stream of the browser. After finishing the business logic there would be a redirect to the next page. We cant use response.sendRedirect() or forward over here. ---- Atul
|
 |
 |
|
|
subject: Showing the status of an operation
|
|
|