Posts

Showing posts from July, 2009

Cron Job (Job scheduler) for Web Application

Image
This Cron job(Timer Task, Job scheduler) Start when web application deploying and run according to give time schedule. For adjust the time want to edit time rage of class.

1. Add following 2 java class in to web application and adjust time with request time period.
2. Add Listener class property in to web.xml


Web XML entry





Listener class

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.itfac.chandana;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
*
* @author Chandana
*/
public class WisdomListener implements ServletContextListener {

private ServletContext context = null;

public void contextDestroyed(ServletContextEvent event) {

System.out.println("Application is undeploying");
this.context = null;

}

public void contextInitialized(ServletContextEvent event) {
this.context = event.getServletContext();
TimerTaskScheduler taskShe = new Tim…