File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Showing the status of an operation

 
sreenath reddy
Ranch Hand
Posts: 415
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chandrashekhar Tupe
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 415
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic