Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

TimerTask and Execute

Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I've a rather strange problem with Action class's "execute" method and the "TimerTask" class. May be my design is incorrect, but here is the problem.

The "execute" method in my "action" class has logic to lookup the database for a user. If the "user" is not found in the database, it tries to push the user information into the database. The database update takes some amount of time to get updated so I cannot display the results for that particular user instantly.

Hence I created a timertask that fires off after ceratin time. the logic inside the timetask tries to query the database and get the user related information. In the mean time, In the mean time I'm trying to show a progress page to the user saying that information is getting retrieved.

Once the timer task has completed its work, it tries to invoke a forward on another page that displays results. (An inner class is written that extends TimeTask and it fetches data from database)

I'm not able to forward to the results page from "timertask" class. I was wondering if anyone can help me solve this issue.

pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't push the results to the browser if a response (the wait page) was already returned; the browser must make another request to see if the process is completed.

A common way of handling this is to include a delayed refresh in your wait page to ask the server, "Are you done yet?" If the process has not completed, the server will respond with the wait page again.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic