aspose file tools*
The moose likes Servlets and the fly likes Auto Notification - Email Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Auto Notification - Email" Watch "Auto Notification - Email" New topic
Author

Auto Notification - Email

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
Hi all,

I am working at a project in JSP and Servlet. I am trying to add this functionality in my project. I want to automatically sent the email to particule person and particulr time. I had written the program in servlet and by compling and running the class file, the mail is auotmatically sent to the person. But What I want is it should be automatically run the class file, so that it can sent the mail.

I had written the business logic in the servlet, it will check the persons to be auto notify thu' email from th oracle DB and get the mail id of the persons to be sent. If I run the class file, mail is automatically send.

I want to run this class file on every monday at 3.00 pm. How can I do this. I tried in adding in the windows scheduled task, but the class file is opening and it has to run the class file, so that it can send the mail.

Please guide me in right direction in this regard.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61215
    
  66

Servlets are a very poor technology choice for this. Servlets are designed to be triggered by a request from a browser in order to create a response to send back. None of this matches your requirements.

I'd write a standalone Java program that could be scheduled to run when you need it to that performs this function.
[ March 27, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
Whether is is possible to write a thread and call it in the context listener will work.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
How about using something like Cron for Windows to schedule execution of your program (you only need an ordinary Java class).


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
kwame Iwegbue
Ranch Hand

Joined: Sep 02, 2000
Posts: 197
I have a similar application. why don't you try java.util.TimerTask

schedule a Timer and place the code that starts the timer in something like a jsp declaration.


Who dares, wins! (SAS motto)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61215
    
  66

In a JSP?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
When writing code to send mail, always remember that the mail server is a separate application - it may not even be running when you try to send, or it may reject your first try for some reason. Therefore, provide for recovery from sending errors, keeping the mail and later trying again - don't just drop the mail in the bit-bucket.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Auto Notification - Email