0
votes

My Requirement - Display list of scheduled jobs on a web page.

What I have accomplished so far-

1) I am initializing the scheduler using a servlet and making appropriate entries in web.xml.

Servlet

public class QuartzTest extends HttpServlet implements Job {
    public static Scheduler scheduler = null;
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
    // Get details from web form and schedule a job accordingly.
    }
}

2) I am successfully storing the job,trigger & schedule details in a Sybase database.

quartz.properties

org.quartz.scheduler.instanceName = MyJobScheduler
org.quartz.scheduler.instanceId = 1
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5
########################################
########### SYBASE CONNECTION ##########
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.SybaseDelegate
org.quartz.jobStore.dataSource = SybaseDS
org.quartz.jobStore.useProperties = true
org.quartz.dataSource.SybaseDS.driver = com.sybase.jdbc3.jdbc.SybDriver
.
.
.

My Problem I am trying to show the scheduler details on a web page. Below is the Java class I have written to do so, and I am trying to access this class from a JSP page, but I am getting NullPointerException-

My Class

public class JSPtest {
    // Method to get scheduler name
    public ArrayList<String> getSchedulerName() {
        ArrayList<String> jobList = new ArrayList<String>();
        String name = null;
        try{
            name = QuartzTest.scheduler.getSchedulerName();
            jobList.add(name);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
        return jobList;
    }
}

JSP

<%! 
JSPtest jsp = new JSPtest();
ArrayList<String> jobList = new ArrayList<String>();
int count = 0;
%>
<%
jobList = jsp.getSchedulerName();
for(count = 0; count < jobList.size(); count++){
    out.println("<p>"+jobList.get(count)+"</p>");
}
%>

Error

java.lang.NullPointerException
    at com.globeop.quartztrials.JSPtest.getSchedulerName(JSPtest.java:32)
    at org.apache.jsp.viewSchedule_jsp._jspService(viewSchedule_jsp.java:72)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

So how do I display the scheduler details on a web page ?

1

1 Answers

0
votes

Check out jwatch which has all you need to display jobs.