File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes TimerTask and Execute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "TimerTask and Execute" Watch "TimerTask and Execute" New topic

TimerTask and Execute

saikiran surya

Joined: Jun 04, 2004
Posts: 16
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.

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

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.

A good workman is known by his tools.
I agree. Here's the link:
subject: TimerTask and Execute
It's not a secret anymore!