Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Progress of operation in web apps ?  RSS feed

 
Jiri Nejedly
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have j2ee web application. Thre is some operation, which I start by pressing button on jsp page. The operation takes let's say two minutes.
New page is generated only after the opration is done. Is there any technique to continuously display progress in web application? Is timer needed ?
The only way I saw (on Oracle AS server) is self-refreshing page, which continously says, that operation is in progress and will stay so, even if the page is closed. When opearion ends, something is set and and a 'done' page is generated. But is there any bettter way ? Precentage ? I presume that the operation can tell at any moment, how much percent remains to be done.

Any ideas will be welcomed. Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The technique that you described is really the best way to handle this.
A user shouldn't be expected to wait at a screen for two minutes.

If something is going to take that long a user should expect to be able to move on to something else while it is processing and come back to check the status. Ideally, your application should send the user an email when it's done so they don't even need to check back.

I have a sample app that shows one of implementing a refreshing status screen on my own site.
http://simple.souther.us/not-so-simple.html
Look for LongRunningProcess.
 
Jiri Nejedly
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, very good example. I have one more question - does this technique mean, that using threads (class implementing runnable) is necessary ? We have an old j2ee application, which uses threads (timers) and when we deployed it onto Oracle AS, there must have been option -Doc4j.userThreads=true enabled. So are the threads necessary ? Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used threads and session variables in this example because I wanted the whole app to fit in a war file.

Where I work we have a similar situation but instead of using Java thread, a new process is kicked off in the core application (not written in Java). Instead of using session variables (as I did in the demo app) all the state is stored in the database.
This allows users to log out and come back in to check the progress of the operation. Other users can also see what reports are being generated and retrieve them when they're done.

However you implement it, the point is to kick off the operation, and return a response right away instead of trying to hold an HTTP connection open until the long running operation is complete.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!