我的要求 - 在网页上显示计划作业列表。
到目前为止我所取得的成就——
1) 我正在使用 servlet 初始化调度程序并在 web.xml 中进行适当的条目。
小服务程序
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) 我成功地将作业、触发器和计划详细信息存储在 Sybase 数据库中。
石英属性
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
.
.
.
我的问题我正在尝试在网页上显示调度程序详细信息。下面是我为此编写的 Java 类,我试图从 JSP 页面访问这个类,但我得到 NullPointerException-
我的课
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>");
}
%>
错误
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)
那么如何在网页上显示调度程序详细信息?