Ever since the initial availability of the Tomcat server, some developers have wanted or needed to create applications that have full control over the server's lifecycle and internal operation. When the entire Tomcat server is contained within a custom application, it is said to be operating in embedded mode. While provisions were made for embedding Tomcat into applications in past releases (as far back as Tomcat 3.x), these older provisions were rather ad hoc and problem-prone because the earliest versions of Tomcat did not account for the embedded mode of operation. Tomcat 5 changed this landscape completely. Embedded operation is an explicitly supported mode, and Tomcat 6 and future Tomcat designs will evolve to satisfy the emerging requirements from embedded users.
This chapter explores the embedded mode of Tomcat 6 in the following areas:
Why embedding Tomcat may be important for many projects
Programmatically embedding Tomcat
Developing a real embedded Tomcat application
Hands-on examples are provided so that you can experiment with configuring embedded Tomcat instances. This chapter focuses more on the under-the-hood aspects of embedded Tomcat implementations.
By the end of this chapter, you should have a comprehensive understanding of why you might use embedded mode and how to operate Tomcat in embedded mode. You will be able to facilitate the creation of applications and systems that operate embedded Tomcat instances.
Tomcat versions before 6.x included ...