aspose file tools
The moose likes Servlets and the fly likes Invoking a servlet on a time based event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Invoking a servlet on a time based event" Watch "Invoking a servlet on a time based event" New topic

Invoking a servlet on a time based event

Harshavardhan Joshi

Joined: Sep 27, 2011
Posts: 8

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.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31571

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
Please check usage of Quartz that may be useful to you.
subject: Invoking a servlet on a time based event