• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scheduled Task in Struts

 
Anna Santiago
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I'm new to struts 1 and I was just wondering if scheduled tasks can be created using the framework?

I've tried the Timer and TimerTask classes to do the scheduling and created an instance of it in my PlugIn file(class file which implements the struts Plugin) but still it only do the task once..

Any help would be appreciated. thanks thanks
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts is a web framework. If you want to do any scheduled tasks, use something like Quartz or Java TimerTask.
 
Anna Santiago
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Freddy,

Actually I already used the TimerTask paired with the Timer... but the task is only executed once.

You see what I'm currently implementing now is caching some data from the database by using the PlugIn of struts... but I also need to update the cached data every 2 hours for example..
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I didn't read your question carefully. My bad.


Actually I already used the TimerTask paired with the Timer... but the task is only executed once.

That's weird. If you call Timer.scheduleAtFixedRate(), the last argument has period where you can set the task to run repeatedly.

Can you provide your code how you do that?
 
Anna Santiago
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I used Timer.schedule(new TimerTask(){...}, 6000)... but I already used Quartz and its working now...

but I think Quartz is too heavy for what I'm doing now. thank you for replying
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic