Apache Tomcat 7 Essentials - Tanuj Khare - E-Book

Apache Tomcat 7 Essentials E-Book

Tanuj Khare

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Apache Tomcat (or simply Tomcat) is an open source servlet container developed by the Apache Software Foundation (ASF). The latest major stable release, Apache Tomcat version 7 implements the Servlet 3 and JavaServer Pages 2 specifications from the Java Community Process, and includes many additional features that make it a useful platform for developing and deploying web applications and web services.Apache Tomcat 7 Essentials follows a practical approach to teach installing, configuring, and maintaining Tomcat. It helps you to understand the middle architecture for hosting multiple websites and also provides the confidence to implement middleware support. It imparts to you the capacity to resolve migration issues and also provides regular maintenance solutions. This is the first and only book to cover upgrading to Tomcat 7 from previous versions.The journey of the reader starts at the beginner level and ends at the expert level. The content is designed in such a way that it balances the theory and practical approach for understanding concepts related to handling middle ware and web issues.In this book, you will go through a three-phase life cycle. The first cycle consists of installation, configuration of Tomcat 7 on different OS, and other configurations related to JDBC, port, deployment etc. The second phase deals with the building of enterprise application setup and high availability architecture (clustering load balancing). The third and critical phase will teach you to handle critical issues, performance tuning, and best practices for various environment stacks like dev/QA/stage/production.This book gives you a wider vision of using Tomcat 7 in web technologies and the skill to optimize their performance using Apache Tomcat 7.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 257

Veröffentlichungsjahr: 2012

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Apache Tomcat 7 Essentials
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Installation of Tomcat 7
History of Tomcat
Tomcat support matrix
Features and enhancements of Apache Tomcat 7
Web application memory leak detection and prevention
Servlet 3.0
Improved logging
Aliases
Installation of Tomcat 7
How to download the Tomcat software
Binary package
RPM/exe
Source
Prerequisites for the Tomcat 7 installation
Installation of Java
Installation of Java in Linux
Installation of Java in Windows
Configuration of OS environment variables
What is JAVA_HOME?
Setting the JAVA_HOME and PATH variable in Windows
Setting the global path variable in Windows
Setting the JAVA_HOME and the PATH environment variable in Linux
Installation of Apache Tomcat 7
Installation on a Windows environment
Installation on a Linux environment
Startup and shutdown of Tomcat services
Services in Windows
Services in Linux
Startup script
Shutdown script
Verification of Tomcat status
Common problems and troubleshooting in installation
Error: Permission denied for the Java binary
Error: Tomcat is not able to find JAVA_HOME
Error: Error in the logs showing port already in use
Summary
2. Configuration and Deployment
Configuration files and their usage
Configuration of Tomcat 7
DataSource configuration
JDBC
JNDI
DataSource
DataSource for Oracle
DataSource for MySQL
DataSource for PostgreSQL
Comparison of the datasource for common databases
Tomcat Manager configuration
Enabling the Tomcat Manager
Context path
Enabling the context path
GUI using the Tomcat Web Application Manager
Command-line configuration in server.xml
Deployment in Tomcat 7
Structure of the WebArchive
Archive Files
Exploded archive directories
Deployment operations
Types of deployment
Ways of application deployment in Tomcat 7
Common issues in deployment, configuration, and their troubleshooting
Summary
3. Performance Tuning
Performance tuning for Tomcat 7
Why we need performance tuning?
How to start performance tuning
Tomcat components tuning
Types of connectors for Tomcat 7
Java HTTP Connector
Java AJP Connector
APR (AJP/HTTP) Connector
Thread optimization for Tomcat 7
Shared thread pool (shared executor)
Dedicated thread pool
Shared thread pool versus dedicated thread pool
maxThreads
maxKeepAlive
JVM tuning
Why do we need to tune the JDK for Tomcat?
JMAP (Memory Map)
Syntax for jmap
How to increase the heap size in Tomcat 7
Garbage collection
How garbage collection works
JVM options
Standard options
Non-standard options
Parameters displayed in the logs for GC
SurvivorRatio
OS tuning
Summary
4. Integration of Tomcat with the Apache Web Server
User request flow (web/application level)
Why the Apache HTTP server
Installation of the Apache HTTP
Apache HTTP installation on Windows
How to monitor the Apache service
Installation of Apache HTTP on Linux (non-DOS environment)
Apache Portable Runtime
Installation of APR/APR-util
Apache Jserv protocol
Installation and configuration of mod_jk
Installation of mod_jk
Configuration of mod_jk in Apache
mod_proxy configuration
Comparison between mod_jk and mod_proxy
IIS integration with Tomcat 7
Prerequisites
Steps for installation
Common issues and troubleshooting for integration
Summary
5. Securing Tomcat 7
Tomcat Manager
Tomcat security permissions
catalina.properties
catalina.policy
System Code permissions
Catalina Code permissions (Tomcat core permission)
Web application permissions
tomcat-users.xml
server.xml
Enabling Tomcat Manager
How to enable the Tomcat Manager
Securing Tomcat 7 for production
Tomcat settings
Connector Port
Slimming of Tomcat application
Disable hot deployment
Non-Tomcat settings
Service as a separate user
Firewall
Password
SSL configuration on Tomcat 7
Types of SSL certificates
Process of installing SSL
Summary
6. Logging in Tomcat 7
JULI
Loggers, appenders, and layouts
Types of logging in Tomcat 7
Application log
Server log
Console log
Access log
Host manager
Types of log levels in Tomcat 7
Log4j
Log level for log4j
How to use log4j
Log level mapping
Values for Tomcat 7
Log analysis
Helpful commands for log analysis
Summary
7. Troubleshooting in Tomcat
Common problem areas for web administrators
How to troubleshoot a problem
Slowness issue in applications
How to solve slowness issues in Tomcat 7
User end troubleshooting
Web server troubleshooting
Tomcat 7 troubleshooting
Troubleshooting at the database level
Telnet DB server IP port
JVM analysis in the Tomcat instance
How to obtain a thread dump in Tomcat 7
Thread dump using Kill command
Thread dump using jstack
How to analyze the thread dump for Tomcat instance
Thread dump analysis using Samurai
Thread dump analysis using the Thread Dump Analyzer
Errors and their solutions
JVM (memory) issues
Out of Memory exception
OutOfMemoryError: PermGen space
Stack over flow exception
Database-related issues
Broken pipe exception
Timeout waiting for an idle object
Database connectivity exception
Web server benchmarking
ApacheBench
JMeter
Summary
8. Monitoring and Management of Tomcat 7
Different ways of monitoring
Monitoring setup for a web application and database server
Tomcat Manager in Tomcat 7
Monitoring in Tomcat 7
Summary of the Server Status of Tomcat 7
Complete Server Status of Tomcat 7
Application List
JVM
Connections on the HTTP port (8080)
Connections on the AJP
JConsole configuration on Tomcat 7
Remote JMX enabling
How to connect to the JConsole
Different tabs for the JConsole and their features
Memory overview
Threads overview
VM Summary and Overview
MBeans
Types of MBeans
Summary
9. Clustering in Tomcat 7
What is a cluster?
Benefits of clustering
Disadvantages of clustering
Clustering architecture
Vertical clustering
Advantages of vertical clustering
Disadvantages of vertical clustering
Horizontal clustering
Advantages of horizontal clustering
Disadvantages of horizontal clustering
Vertical clustering in Apache Tomcat 7
Installation of the Tomcat instance
Configuration of a vertical cluster
Configuration of instance 1
Configuration of instance 2
Apache web server configuration for vertical clustering
Horizontal clustering in Apache Tomcat 7
Installation of the Tomcat instance
Configuration of the cluster
Configuration of instance 1
Configuration of instance 2
Apache web server configuration for horizontal clustering
Testing of the clustered instance
Monitoring of Tomcat clustering
Summary
10. Tomcat Upgrade
Different types of environment
Development environment
Quality Assurance environment
Staging environment
Production environment
Life cycle of the upgrade
Tomcat upgrade from 6 to 7
Prerequisites for Tomcat 7
Installation of Tomcat 7 for the upgrade
Configuration of Tomcat 7
JVM configuration
Database connection settings
Application migration
Alias configuration
ITIL process implementation
Availability management
Capacity management
Service Transition
Summary
11. Advanced Configuration for Apache Tomcat 7
Virtual hosting
Name-based virtual hosting
IP-based virtual hosting
Virtual hosting in Tomcat 7
Hostname aliases
Multiple applications hosting on a single Tomcat 7 instance
Multiple Tomcat environments—Development/QA/Stage/Production
Tuning cache
Optimization of Tomcat 7
Running Tomcat 7 as a non privileged user
Summary
Index

Apache Tomcat 7 Essentials

Apache Tomcat 7 Essentials

Copyright © 2012 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: March 2012

Production Reference: 1160312

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK..

ISBN 978-1-84951-662-4

www.packtpub.com

Cover Image by Vinayak Chittar ( <[email protected]> )

Credits

Author

Tanuj Khare

Reviewers

Zeeshan Chawdhary

Ty Lim

Vidyasagar N V

Acquisition Editor

Usha Iyer

Lead Technical Editor

Susmita Panda

Technical Editor

Unnati Shah

Copy Editor

Laxmi Subramanian

Project Coordinator

Vishal Bodwani

Proofreader

Linda Morris

Indexer

Rekha Nair

Graphics

Valentina D'Silva

Manu Joseph

Production Coordinator

Alwin Roy

Cover Work

Alwin Roy

About the Author

Tanuj Khare has been a professional in IT for over six years. He is involved in process improvements using the ITIL framework and techniques such as Lean Six Sigma. He is MCSA and ITIL certified, and has expertise in handling critical production server issues. He also has a track record of dealing with many complex problems. His quick resolution to issues faced in the production environment has helped his team and clients in a big way.

Tanuj has Subject Matter Expertise (SME) in Tomcat, WebLogic, and JBoss server administration. His experience includes working with large-enterprise web hosting environments for J2EE containers with small teams, and his quick turnaround time gave on-time delivery. Apart from this, his technical expertise in Root Cause Analysis, Problem Management, Migration of enterprise applications, and upgrade of web application servers are commendable. Up to now, he has migrated more than 100 enterprise applications and upgraded J2EE web applications. He has also managed environments with over 1000 middleware instances.

Apart from work life, Tanuj enjoys playing Table Tennis and exploring new technologies. He is a good dancer. This is his first book.

Acknowledgement

I would like to express my gratitude to all the people who have helped me to make this book better. I thank Ranveer Chandel, who has helped me to provide high technical standards for this book.

I would like to thank Archana Kannoujia, who has patiently helped me to improve my writing style.

I would like to thank Mitesh Parikh and Giri Moturi for their support.

I would like to thank Usha Iyer, Vishal Bodwani, Susmita Panda, and everyone else at Packt Publishing for all their hard work to get this book published. A special thanks to Unnati Shah for her hard work and dedication to get this book published.

I would like to thank Ty Lim,Vidyasagar N V, and Zeeshan Chawdhury for providing their valuable guidance and support that helped me achieve the high technical standards.

And finally, I'd like to thank all my colleagues and friends, with whom I've worked throughout my career, for contributing to my professional development.

About the Reviewers

Zeeshan Chawdhary is the CTO of Wcities Inc., a location-based travel content provider, running technical operations from their Technical Headquarters in Mumbai.

He is a do-it-all and code-in-any-language guy, having worked with various technologies from 3D gaming to consumer websites, from iPhone apps to serving over 30 million hits over the Cloud.

He is currently writing two real-world-use books with Packt Publishing which are, iPhone Location Aware Applications by Example - Beginners Guide and Windows Phone 7.5 - Building Location Aware Applications.

He can be reached at imzeeshan on Twitter. He currently blogs at http://justgeeks.in.

I would like to thank the great people at Packt for letting me review this book. Special thanks to Vishal Bodwani, Susmita Panda, Leena Purkait, Amey Kanse, Alina Lewis, and a special mention for Mary Nadar, for having introduced me to the Packt family.

Ty Lim has been in the IT industry for over 15 years. He has worked for several startup companies in the mid 1990s and found himself working at several major corporations after his stint in Silicon Valley. He has worked in the following industries: Software Development, Consulting, Healthcare, Telecommunications, and Finance. He has experience in utilizing JBoss, Tomcat, and WebSphere middleware technologies. He holds a Bachelor of Science degree in Computer Science from the University of the Pacific, and is currently pursuing a Master of Science degree in CIS from Boston University.

He has also worked on IBM WebSphere Application Server v7.0 Security, Packt Publishing.

I would like to thank all my friends and family for their continued support. I am truly blessed to have such great support. It is because of all of you that I consider myself a very happy man.

Vidyasagar N V was interested in Computer Science since his early age. Some of his serious work in computers and computer networks began during his high school days. Later, he went to the prestigious institute of technology, Banaras Hindu University for his B.Tech. He has been working as a Software Developer, Data Expert, developing and building scalable systems since then. He has worked with a variety of 2nd, 3rd, and 4th generation languages. He has also worked with Flat files, Indexed files, Hierarchical databases, Network databases, Relational databases, NoSQL databases, Hadoop, and related technologies.

Currently, he is working as a Senior Developer at Ziva Software Pvt. Ltd, developing a big data-based structured data extraction technique from the Web and local information. He enjoys producing high-quality software, web-based solutions, and designing secure and scalable data systems.

He has also worked on PHP and MongoDB Web Development Beginner's Guide, Packt Publishing.

He can be reached at <[email protected]>.

I thank the almighty for giving me such a blessed life and thank my parents, Mr. N. Srinivasa Rao and Mrs. Latha Rao, and my family who supported and backed me throughout my life. I thank my friends and all those people who donated their time, effort, and expertise by participating in open source software projects. Also, thanks to Packt Publishing for selecting me as one of the technical reviewers for this wonderful book. It is my honor to be a part of this book.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

I would like to dedicate this book to my mom, Mrs. Shashi Khare and dad, Mr. Rajkumar Khare, for standing beside me during the writing of this book.

Without their support and encouragement, completing this book would have been a much more difficult task.

Preface

This book will help you resolve these issues and boost your confidence in handling Apache Tomcat 7 administration using the tips, tricks, and best practices used by various industry experts to maintain their middleware infrastructure. The best thing that the author did while designing the content is a practical solution, with a detailed description of why we are doing this solution.

Apache Tomcat (or Jakarta Tomcat, or simply Tomcat) is an open source servlet container developed by The Apache Software Foundation. The latest major stable release, Apache Tomcat version 7, implements the Servlet 3 and JavaServer Pages 2 specifications from the Java Community Process. It includes many additional features that make it a useful platform for developing and deploying web applications and web services.

Apache Tomcat 7 Essentials follows a practical approach to explain installing, configuring, and maintaining Tomcat. It helps you to understand the middleware architecture to host multiple websites and also provides the confidence to implement middleware support. It imparts to you the capacity to resolve migration issues and also provides regular maintenance solutions. This is the first, and only, book to cover upgrading to Tomcat 7 from the previous versions.

The journey of the reader starts at the beginner's level and ends at the expert level. The content is designed in such a way that it balances the theory and practical approach for understanding concepts related to handling middleware and web issues.

In this book, you will go through a three-phase life cycle. The first cycle consists of the installation, configuration of Tomcat 7 on different OSes, other configurations related to the JDBC, port, deployment, and so on.

The second phase deals with the building of an enterprise application setup and high availability architectures (clustering and load balancing). The third and critical phase will teach you to handle critical issues, performance tuning, and the best practices for various environments such as Dev/QA/Stage/Production.

This book gives you a wider vision of using Tomcat 7 in web technologies and the skill to optimize its performance using Apache Tomcat 7.

What this book covers

Chapter 1, Installation of Tomcat, covers the Apache Tomcat history and the new features introduced in Tomcat 7. The step-by-step installation of Tomcat 7 on Windows and Linux operating systems and common problems that may arise during the installation and their possible solutions are also discussed.

Chapter 2, Configuration and Deployment, covers the configuration of Tomcat including the DataSource configuration for different databases such as Oracle, MySQL, and PostgreSQL, and Context Path creation using an application. Various ways to perform deployment including deployment using Tomcat Manager for a sample application and troubleshooting common issues are also discussed.

Chapter 3, Performance Tuning, explains the different ways of performance improvement and techniques in Apache Tomcat 7. Step-by-step configurations for Connectors, JVM performance tuning, and OS parameter optimization are also covered.

Chapter 4, Integration of Tomcat with the Apache Web Server, explains the integration of Apache/IIS with Tomcat 7, integration of various components such as mod_jk, mod_proxy, and real-time issues which may arise during integration, along with their solutions.

Chapter 5, Securing Tomcat 7, explains the various policies of Tomcat 7 and its functionalities such as the Catalina policy and System level policy. Measures to enable security and their benefits such as SSL, best practices used in real-time industries to secure Tomcat 7 in the production environment, by doing the configuration change and SSL implementation are also covered.

Chapter 6, Logging in Tomcat 7, explains the different methods of enabling logs in Tomcat 7—log4j and JULI. Also, the best practices used for log analysis, tips, and tricks are discussed.

Chapter 7, Troubleshooting in Tomcat, covers different issues faced by the application/web administrators in a real-time environment, how to avoid these issues in the production environment using different techniques with errors and their solutions, thread dump analysis and tools used for thread dump analysis, memory issues, steps for troubleshooting real-time problems, and web server benchmarking.

Chapter 8, Monitoring and Management of Tomcat 7, explains various processes of monitoring in Tomcat 7, components using Tomcat Manager and JConsole, such as different ways of monitoring, how monitoring is done in Tomcat 7, JConsole, and how it is used.

Chapter 9, Clustering in Tomcat 7, explains clustering of Tomcat 7 and its implementation technique. Topics included are clustering architecture, horizontal and vertical clusters and their benefits, implementation of horizontal and vertical clustering on Tomcat 7, and verification of clusters.

Chapter 10, Tomcat Upgrade, explains various strategies used in the upgrade from Tomcat 6 to Tomcat 7 and the various steps followed during the upgrade process such as the life cycle of the upgrade, upgrade configuration of Tomcat 7, DataSource configuration, and discussions on various ITIL processes used during upgrade.

Chapter 11, Advanced Configuration for Apache Tomcat 7, explains the advanced configuration of Tomcat 7 and its optimization parameters. Key points covered in the environment are virtual hosting, features of Development/QA/Stage/Production, Tomcat as a service, and running Tomcat as a non privileged user.

What you need for this book

To understand the contents of this book, you should have a basic knowledge of Windows or Linux operating systems and it is an added advantage if you have some knowledge in Java.

Who this book is for

If you are a J2EE Administrator, Migration Administrator, Technical Architect, or Project Manager for a web hosting domain, and are interested in Apache Tomcat 7, then this book is for you. If you are responsible for the installation, configuration, and management of Tomcat 7, then this book will be of help to you too.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Due to Tomcat 7's support for web fragments, developers now don't need to implement the specific library configurations for their application web.xml."

A block of code is set as follows:

# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ];then . ~/.bashrc fi # User specific environment and start-up programs JAVA_HOME=/opt/jdk1.6.0_24 PATH=$JAVA_HOME/bin:$PATH:$HOME/bin export PATH JAVA_HOME unset USERNAME

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<Executor name="tomcatThreadPool "namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/>

Any command-line input or output is written as follows:

[root@localhost opt]# cksum apache-tomcat-7.0.12.zip

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The previous screenshot shows the packages which are available in md5, and by clicking on md5 on the website, we can compare the checksum generated in our system with the value given on the site."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Installation of Tomcat 7

Apache Tomcat is an open source Java-based web and servlet container, which is used to host Java-based applications. It was first developed for Jakarta Tomcat. Due to an increase in demand, it was later hosted as a separate project called Apache Tomcat, which is supported by The Apache Software Foundation. It was initially developed by James Duncan Davidson, a software architect at Sun Microsystems. He later helped make this project open source and played a key role in donating this project from Sun Microsystems to The Apache Software Foundation. Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a "pure Java" HTTP web server environment for Java code to run.

Apache Tomcat version 7.0 implements the Servlet 3.0 and Java Server Pages 2.2 specifications from the Java Community Process. It includes many additional features that makes it a useful platform for developing and deploying web applications and web services.

In this chapter, we will discuss the following topics:

Introduction to Tomcat 7Features of Tomcat 7Installation of Tomcat
Prerequisites for Tomcat 7 installationInstallation on Linux and Windows operating systems
Common areas of troubleshooting during installation

History of Tomcat

Tomcat was first introduced to the open source group in 1999 and its first version was released with 3.0.x version. Since then, it has been greatly supported by the open source community and widely accepted in the IT industry. In the current scenario, Tomcat is running in production environments, as well as being used for mission-critical projects in various industries. The following mentioned details give us a quick history of the versions.

Over the 12 years of of its successful journey, Tomcat has reached various states and given the IT industry various releases. Tomcat road maps outlined with their stable releases are mentioned as follows:

Version

Release Date

Description

3.0.x. (initial release)

1999

Merger of donated Sun Java Web Server code and ASF, and implements Servlet 2.2 and JSP 1.1 specifications.

3.3.2

March 9, 2004

Latest 3.x release.

4.1.40

June 25, 2009

Latest 4.x release.

5.5.32

February 1, 2011

Latest 5.x release.

6.0.32

February 3, 2011

Latest 6.x release.

7.0.0 beta

June 29, 2010

First Apache Tomcat release to support Servlet 3.0, JSP 2.2, and EL 2.2 specifications.

7.0.11

March 11, 2011

Fourth stable version.

7.0.12

April 6, 2011

Current stable version.

Note

For more information on version changes, release, and comparison, visit http://en.wikipedia.org/wiki/Apache_Tomcat and http://wiki.apache.org/tomcat/FrontPage.

Tomcat support matrix

Apache Tomcat can be classified based on different components, such as the JDK version, enhancement, stability, and so on. Let's take a real time example, where you want to take a decision on which Apache Tomcat version to deploy for an application. For example, if an application is using Servlet 2.4 and JSP 2.0, then we should always go for the 5.x version. In reality, it's a difficult job to find out which version of Tomcat we should use to utilize the system resource properly.

Normally, these tasks would be done by the company's technical architect, and they are solely responsible for the technical specifications used in any product. Based on the features of Tomcat, let us quickly go through the comparison of Tomcat with different versions:

Features

7.x

6.x

5.x

4.x

3.x

Version specifications

Servlet 3.0, JSP 2.2, EL 2.2

Servlet 2.5, JSP 2.1

Servlet 2.4, JSP 2.0

Servlet 2.3, JSP 1.2

Servlet 2.2, JSP 1.1

Stable:

Yes

Yes

Yes

Yes

Yes

Enhancements

Yes

Yes

Unlikely

Highly unlikely

Highly unlikely

Bug Fixes

Yes

Yes

Yes

Highly unlikely

Highly unlikely

Security Fixes

Yes

Yes

Yes

Highly unlikely

Highly unlikely

Releases

Yes

Yes

Yes

Highly unlikely

Highly unlikely

Release Manager

Mark Thomas (markt)

Jean-Frederic Clere (jfclere)

Filip Hanik (fhanik)

Mark Thomas (markt)

Bill Barker (billbarker)

Process

CTR

RTC

RTC

CTR

CTR

Listed on download pages

Yes

Yes

Yes

No

No

JDK version

1.6

1.5

1.4

1.3

1.1

In the previous table, highly unlikely means that the user using the previous version necessarily needs to have the upgraded higher version to support the new improved features. It also involves security fixes for the current version.

Features and enhancements of Apache Tomcat 7

In the previous section, we discussed the various support matrices for Tomcat versions, we are now aware of the support specifications (JDK support, EJB, and Servlet) for Tomcat. Let's try to understand, and quickly review the new features/enhancements for Tomcat 7.

Apache Tomcat 7.x was released with some key improvements over Tomcat 6.x and real time implementation of Servlet 3.0, JSP 2.2, and EL 2.2 specifications. Apart from these, it also solves some major issues from previous releases.

Web application memory leak detection and prevention

Tomcat had a chronological problem of memory leaks in 4.x/5.x versions. While reloading the applications in the entire life cycle of Tomcat, OutOfMemoryError exceptions were generated. Tomcat has put an exceptional effort in tracking down the bugs and issues related to memory, in order to avoid memory leaks.

Servlet 3.0

Tomcat 7 offers great support for Servlet 3.0. Servlet 3.0 helps developers to code very easily and also provides significant support for asynchronous programming techniques. The types of support provided are:

Asynchronous Support: Servlet 3.0's asynchronous support has been fully integrated into Tomcat 7. The biggest advantage of asynchronous programming is that the server doesn't have to wait for the response from the resources. For example, if you have 2000 concurrent users using an application, then we cannot allocate 2000 connections to the database and make the connection idle untill we get the response. By using asynchronous programming, your application can handle other user requests while this particular user is waiting for the response from the resources, such as DB, NAS, and so on.Dynamic Configuration: It is again, a very vital feature of Servlet 3.0. Due to Tomcat 7's support for web fragments, developers now don't need to implement the specific library configurations for their application web.xml. This means, you can integrate the library reference in web.xml.Annotation-based Configuration: With the additional support for Servlet 3.0 in Tomcat 7, developers can include decorative programming styles. The biggest advantage of implementing decorator is you can configure rewrite rules in the application servlet classes instead of web servers. Hence, you reduce the dependency on web servers. It also eliminates the need for deployment descriptors.

Improved logging

Tomcat 7 includes two new features for logging, in order to provide a good understanding to the users for log analysis:

Asynchronous file handler: The asynchronous handler allows Tomcat to write logs to the disk by a dedicated thread, so that logging operations do not cause any delay in processing threads.Single line log formatter: