Integrating Quartz
Fortunately, two things make it easy to integrate Quartz into a Web application. First, the list of third-party libraries the Quartz framework requires is pretty straightforward. Most of the third-party dependencies already are included in any Java Web application, especially ones built with open source frameworks such as Apache Struts. When deploying Quartz within a Web application, Quartz requires the following third-party libraries:
- Commons BeanUtils
- Commons Collections
- Commons Logging
- Commons Digester
If you've built Java Web applications before, you've seen all these listed here. A few other JARs might be necessary, depending on your exact deployment of Quartz. For example, if Quartz stores its job information in a database, the Standard JDBC APIs library (jdbc2_0-stdext.jar) is required, along with possibly the Java Transaction API (jta.jar).
You might also need some optional libraries, depending on the totality of your requirements. For example, if your application needs to send e-mails, you'll need the activation and JavaMail libraries. But this is true whether you are deploying Quartz within a Web application or just as a stand-alone application.
Structure of a Web Application
Over the past several years, the Servlet and JSP specifications have improved and allowed for better portability between tool vendors. This has had a calming effect on the Java development community and allows Web developers to focus on the "real" business needs and not on what has to be done to get the application to deploy and run.
Installing the Quartz Libraries
As in any other Java Web application, the Servlet specification instructs that all JARs (third-party or otherwise) must be placed into WEB-INF/lib. Therefore, one of the first steps is to put the quartz.jar file and its dependent JARs into the WEB-INF/lib directory.
Choosing a Web Application Framework
It's entirely up to you which Java Web application framework you choose to integrate with Quartz. So many frameworks are available that it can be quite overwhelming. To say that one particular framework is better than another is very subjective because a lot has to do with your requirements and skill set. However, a few Web frameworks have proven themselves over time. One example is the Apache Struts framework (formerly known as Jakarta Struts). For the purpose of this section, we will use the Struts framework to demonstrate how to integrate with Quartz.