I want to invoke a method from servlet when system clock reach to 12pm and that method basically send some data from database to user via Email.Please can anybody help me how i can achieve this in Java Servlet.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A servlet is the wrong tool for the job. It’s intented to act on HTTP requests, nothing more. You want just a background task which runs once on daily basis. You can’t expect from an enduser that s/he should fire a HTTP request at exactly that moment in order to trigger a “background job”.
Apart from the legacy Quartz library as mentioned by many others (apparently hanging in legacy J2EE era), you can also just use the standard Java SE API provided
ScheduledExecutorServicefor that. This needs to be initiated by a simpleServletContextListenerlike this:Where the class
SendEmaillook like this:That’s all. No need to mess with a legacy 3rd party library.