Why an Entire Book on Tomcat?

Can't you just download and run Tomcat from the Apache Software Foundation's web site? Well, of course you can, and you'll need to, but there is a lot more to Tomcat than just getting it running. You'll get more out of Tomcat if you understand how and why it was written. So in Chapter 1, we explain that. You will then be better able to make informed decisions on choices you might need to make when installing Tomcat, so we spend the rest of the chapter on the installation and startup procedures.

In Chapter 2, we show you all about configuring Tomcat. We talk about when you should use Tomcat as a standalone web server and servlet container and when it's best to use Tomcat with the Apache httpd web server. Then, we show you how to configure realms, roles, users, servlet sessions, and JNDI resources, including JDBC DataSources. Next, we show how to turn on and off the auto-reloading of servlets, how to relocate the webapps directory, and how to map user home directories for access through Tomcat. Then, we go over how to enable and disable the example web applications and how to enable common gateway interface scripting in Tomcat. And finally, we close out the chapter by introducing you to the Tomcat administration web application, which allows you to configure Tomcat through your web browser.

With Tomcat installed and configured just the way you like it, you're ready to learn more about servlet and JSP web applications and how to deploy them into your Tomcat. In Chapter 3, we show you the layout of a web application, how to deploy a web application, and how to deploy individual servlets and JSP pages. Next, we show you how to build web application archive files and how to deploy them. To make things less tedious, we review how to automate the deployments of your web applications by copying, using the built-in manager web application, and using the Jakarta Ant build tool.

Once you have Tomcat serving your web application, you may want to do some performance tuning. In Chapter 4, we show you how to measure and improve your Tomcat's performance. We go over adjusting the number of processor Threads, JVM and OS performance issues as they relate to Tomcat, turning off DNS lookups, and how to speed up JSPs. We round out the chapter by discussing how capacity planning can affect performance.

Tomcat works as a complete standalone web server. It supports static web pages, external CGI scripts, and many of the other paraphernalia associated with a web site. However, Tomcat's forte, its raison d'etre, is to be the best servlet and JSP engine on the block. These are the things it does best. If you already run Apache's httpd web server and don't want to change everything all at once, Chapter 5, covers the use of Tomcat with Apache httpd and talks about the several ways of making Tomcat thrive "in front of" or "behind" an Apache httpd installation.

Whether you're providing e-commerce, putting up a mailing list, or running a personal site, when you're connected to the Internet, your site is exposed to a lot of people, including a few weirdos who think it's OK to exploit the vulnerabilities in your server software for fun and/or profit. Because security is important, we devote Chapter 6, to the topic of how to keep the online thugs at bay.

In Chapter 7, we talk about the Tomcat configuration files, server.xml and web.xml, as well as tomcat-users.xml, catalina.policy, catalina.properties, and context.xml files. Each can be modified to control how Tomcat works.

When something goes wrong with your Tomcat or a web application, Chapter 8, shows you some ways to diagnose the problem. We show you what to look for in the logfiles, how the web browser interacts with Tomcat's web server during a request, how to get verbose information about a particular request, and what to do if Tomcat just won't shut down when you tell it to.

Not everyone wants to run a prebuilt binary release of Tomcat, so in Chapter 9, we show you how to compile your own Tomcat. We show you step-by-step how to install the Apache Ant build tool, download all necessary support libraries, and build your Tomcat.

If you've got more request traffic than a single Tomcat can handle, or if you want your site to keep serving requests even if one of your servers crashes, your site may need to run on more than one Tomcat server, or more than one Apache, or a combination of the two. Sometimes the only solution is more hardware. In Chapter 10, we show you some options for running two or more Tomcat servlet containers in parallel for both fault tolerance and higher scalability, and we discuss the pros and cons of various clustering approaches.

In Chapter 11, we give an overview of the Tomcat open source project's community resources, including docs, mailing lists, other web sites, and more. These are valuable resources for solving any problems you may have with future versions of Tomcat, and they can also help you get more involved in the development of Tomcat if that is one of your goals.

Depending on your operating system, installing Java may not be as straightforward as you think. To ensure that Tomcat runs well on your server computer, in Appendix A, we show you step-by-step how to install a Java runtime, and explain some Java issues to watch out for.

Get Tomcat: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.