File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 32793

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]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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.
I agree. Here's the link:
subject: Invoking a servlet on a time based event
It's not a secret anymore!