• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invoking a servlet on a time based event

 
Harshavardhan Joshi
Greenhorn
Posts: 8
Java MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I wanted to know that is there any provision in Listener interface using which I can invoke a Servlet.

Its like scheduling a task at regular intervals.

Currently I am using Resin server which provides this kind of functionality.

You just have to add some tags in your DD as given below.



But I need something which will not be server/container specific.

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34870
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use the Timer service to call another class/method. However, a servlet's doPost/doGet require you to have an Http request open. Which you don't on a timer event. In other words, it would be more logical to call a non-servlet method. You could extract the logic from your servlet into a helper class/method that doesn't depend on the servlet API.
 
Miku Ranjan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please check usage of Quartz that may be useful to you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic