How to start Servlet Automatically | Eklavya Online

How to start Servlet Automatically

If present, calls the servlet’s service() method at the specified times. <run-at> lets servlet writers execute periodic tasks without worrying about creating a new Thread.

The value is a list of 24-hour times when the servlet should be automatically executed. To run the servlet every 6 hours, you could use:

<servlet servlet-name=”test.HelloWorld”>

<run-at>0:00, 6:00, 12:00, 18:00</run-at>

</servlet>