Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto Notification - Email

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether is is possible to write a thread and call it in the context listener will work.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about using something like Cron for Windows to schedule execution of your program (you only need an ordinary Java class).
 
kwame Iwegbue
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JSP?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic