1

Please help me about this issue...

In my application i have calender where user can set the events for particular day.. this event info is store in database.... now i want my application to automatically send an email to that user on that assigned day....

o.k.w
  • 25,490
  • 6
  • 66
  • 63
azhar_salati
  • 1,554
  • 5
  • 28
  • 54

4 Answers4

1

You have to use scheduler(quartz).Most of the applications are using that.Particularly for sending mails.

http://www.roseindia.net/quartz/index.shtml

http://www.quartz-scheduler.org/

https://quartz.dev.java.net/

You can schedule the scheduler to do some action in particular time interval.

DonX
  • 16,093
  • 21
  • 75
  • 120
1

You don't explititly need the Quartz API for such a simple timer task. For this java.util.TimerTask is perfectly suitable.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks guys for your answers..using your guidelines i have understood how to achieve this functionality...instead of using Quartz API i can directly use the TimerTask... – azhar_salati Nov 02 '09 at 14:10
0

Your servlet is running on the back-end. So all you need is to create an endless loop which is regulary checking if an email needs to be send out.

Something like this:

public void run()
{
 isRunning = true;
 while (isRunning)
 {
  performSomething();

 try
 {
  Thread.sleep(someInterval);
 }
 catch (InterruptedException e)
 {
  isRunning = false;
 }

}

Where the performSomething(); method is a synchornized method:

public synchronized void performSomething()
Drejc
  • 14,196
  • 16
  • 71
  • 106
0

How about using cron jobs, you can call URLs with cron job which can be your servlet that handle the logic.

Robert Childan
  • 983
  • 1
  • 12
  • 22