Women in Technology

Hear us Roar



Article:
  Job Scheduling in Java
Subject:   Integrating quartz in a web application
Date:   2005-02-02 04:32:33
From:   Qaurtz
Hi,
I have prepared a class which sends the mail using a method sendMail() having mailing details as its parameters.I am calling this method from a jsp which provides a mailing UI.Its working fine.
The problem is i have to schedule this task n for which I am using Quartz.I did this task in a standalone application using the CronTrigger. But i cant able to implement this job in my web-application.
Somebody help me to get rid of this problem.Also tell me how can implement quartz in web-applications.(In a Clear Way).


ThankQ.

Full Threads Newest First

Showing messages 1 through 8 of 8.

  • Integrating quartz in a web application
    2006-06-07 07:30:15  balaji007 [View]

    hi i needed the code which u have written for sendMail() and how u implemented this in standalone application using cron trigger..
    waiting for u r reply
    • Integrating quartz in a web application
      2007-11-30 00:44:47  prageet [View]

      What's the purpose of Quartz ? and how can we use it in web application? and how to integrate in this.....plz ssend me one example illustrating the above lines......
  • Integrating quartz in a web application
    2006-11-08 05:11:44  shivapaka [View]

    This is the servlet file u have to call

    package com.v2sol;

    import org.quartz.JobDetail;
    import org.quartz.Scheduler;
    import org.quartz.CronTrigger;
    import org.quartz.impl.StdSchedulerFactory;
    import javax.servlet.*;
    import java.io.*;
    import javax.servlet.http.HttpServlet;
    import org.quartz.ee.servlet.*;

    public class ExcelDBServlet extends HttpServlet {

    @Override
    public void init(ServletConfig config) throws ServletException {

    System.out.println("Initializing Scheduler PlugIn for Jobs!");
    super.init(config);
    ServletContext ctx = config.getServletContext();
    Scheduler scheduler = null;
    StdSchedulerFactory factory = (StdSchedulerFactory)
    ctx.getAttribute(QuartzInitializerServlet.QUARTZ_FACTORY_KEY);

    try {
    scheduler = factory.getScheduler();
    JobDetail jd = new JobDetail("job1", "group1",ExcelJob.class);
    CronTrigger cronTrigger = new CronTrigger("trigger1","group1");
    String cronExpr = null;
    cronExpr = getInitParameter("cronExpr");
    System.out.println(cronExpr);
    cronTrigger.setCronExpression(cronExpr);
    scheduler.scheduleJob(jd, cronTrigger);
    System.out.println("Job scheduled now ..");

    } catch (Exception e){
    e.printStackTrace();
    }
    }

    @Override
    public void service(ServletRequest request, ServletResponse response)throws ServletException, IOException {
    PrintWriter pw=response.getWriter();
    pw.print("<html> <body> <h1>");
    pw.print("Please wait,DataBase Operations is performing.............");
    pw.print("</h1></body></html>");
    }
    @Override
    public String getServletInfo() {
    return null;
    }
    }


    -----
    web.xml



    <web-app>
    <servlet>
    <servlet-name>QuartzInitializer</servlet-name>
    <display-name>Quartz Initializer Servlet</display-name>
    <servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <init-param>
    <param-name>config-file</param-name>
    <param-value>quartz.properties</param-value>
    </init-param>
    <init-param>
    <param-name>shutdown-on-unload</param-name>
    <param-value>true</param-value>
    </init-param>

    <init-param>
    <param-name>start-scheduler-on-load</param-name>
    <param-value>true</param-value>
    </init-param>

    </servlet>

    <servlet>
    <servlet-name>first</servlet-name>
    <servlet-class>com.v2sol.StartQuartz</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>first</servlet-name>
    <url-pattern>/fst</url-pattern>
    </servlet-mapping>

    <servlet>
    <servlet-name>one</servlet-name>
    <servlet-class>com.v2sol.ExcelDBServlet</servlet-class>
    <init-param>
    *******<param-name>cronExpr</param-name>
    <param-value>0,30 * * ? * MON-FRI</param-value>
    </init-param>
    </servlet>

    <servlet-mapping>
    <servlet-name>one</servlet-name>
    <url-pattern>/excel</url-pattern>
    </servlet-mapping>


    </web-app>


    • Integrating quartz in a web application
      2007-03-27 06:35:09  screenforsathish [View]

      hai

      i am also implement the quartz concept for email automatic firing operation but it works fine except that job scheduler from cron expression will run with duplicates i dont know what is the reason so what i have to do please it is urgent one please mail me i will explain u clearly

      my email id = g.sathishkumar@yahoo.co.in

      Thank you
    • Integrating quartz in a web application
      2007-03-27 06:35:10  screenforsathish [View]

      hai

      i am also implement the quartz concept for email automatic firing operation but it works fine except that job scheduler from cron expression will run with duplicates i dont know what is the reason so what i have to do please it is urgent one please mail me i will explain u clearly

      my email id = g.sathishkumar@yahoo.co.in

      Thank you
    • Integrating quartz in a web application
      2007-03-27 06:35:11  screenforsathish [View]

      hai

      i am also implement the quartz concept for email automatic firing operation but it works fine except that job scheduler from cron expression will run with duplicates i dont know what is the reason so what i have to do please it is urgent one please mail me i will explain u clearly

      my email id = g.sathishkumar@yahoo.co.in

      Thank you
    • Integrating quartz in a web application
      2007-03-27 06:35:11  screenforsathish [View]

      hai

      i am also implement the quartz concept for email automatic firing operation but it works fine except that job scheduler from cron expression will run with duplicates i dont know what is the reason so what i have to do please it is urgent one please mail me i will explain u clearly

      my email id = g.sathishkumar@yahoo.co.in

      Thank you
    • Integrating quartz in a web application
      2007-05-28 23:52:17  Saravjava [View]

      Hi,

      Anyone can send a code for integrating quartz
      in a web application.I'm using crontrigger.java
      and a simple hello.class.how to convert this standalone java application into web aplication.