aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "TimerTask and Execute" Watch "TimerTask and Execute" New topic
Author

TimerTask and Execute

saikiran surya
Greenhorn

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.

Thanks,
kiran
Marc Peabody
pie sneak
Sheriff

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: http://aspose.com/file-tools
 
subject: TimerTask and Execute
 
Similar Threads
I can't get the struts working
Common JSP/Action displaying confirmation details
User Defined Thread in Action Class
Struts 1.2.9 +text areas.
Call action class from timertask's run method