Tomcat 6 Developer's Guide Build better web applications by learning how a servlet container actually works Damodar Chetty BIRMINGHAM - MUMBAI This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 Tomcat 6 Developer's Guide Copyright © 2009 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, Packt Publishing, nor its dealers or 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 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: December 2009 Production Reference: 1091209 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847197-28-3 www.packtpub.com Cover Image by Vinayak Chittar ([email protected]) This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 Credits Author Editorial Team Leader Damodar Chetty Akshara Aware Reviewers Project Team Leader David O'Meara Manjiri Nadkarni Michael Besosa Karl Espe Project Coordinator Leena Purkait Alok Gupta Arun Lakkakula Indexer Giridhar Reddy Hemangini Bari David Gordhamer Monica Ajmera Chad LaVigne Vladan Pulec Proofreader Raghu Ramakrishnan Jeff Orloff Dan Syrstad Graphics Nilesh R. Mohite Acquisition Editor Sarah Cullington Production Coordinator Shantanu Zagade Development Editor Swapna Verlekar Cover Work Shantanu Zagade Technical Editor Akash Johari Copy Editor Leonard D'Silva This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 About the author Damodar Chetty is a lifelong programmer with almost two decades in the computer software industry. During that period he’s worked in a variety of languages, tools, and technologies, journeying from programming in assembly language, all the way through to Java and Ruby, making some interesting side trips along the way. He has also been fortunate to have worked in a number of Fortune 500 organizations, and to have engaged with a number of world class software engineers, all of which have helped him perfect his craft. He is also the recipient of the US Department of Interior Information Technology award for 2001. Damodar has an undergraduate degree in Electronics & Telecommunications Engineering from the University of Bombay and graduate degrees in Management Sciences from the University of Goa and in Computer Engineering from the University of Minnesota. He is the owner of Software Engineering Solutions, Inc., a provider of Java EE web development consulting services. He is an avid blogger on his web site at www.swengsol.com. He currently lives in Woodbury, Minnesota with his wife Devi, his children Ashwin and Anita, and a passion for photography. This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 Acknowledgement No book is the product of just the author. He just happens to be the one with his name on the cover. A number of people contributed to the success of this book, and it would take more space than I have to thank each one individually. A special shout out goes to Sarah Cullington, my editor, who is the reason that this book exists. Thank you Sarah for believing in me and for being a wonderful guide through this process. Thank you also to the entire Packt Publishing team for working so diligently to help bring out a high quality product. No words can express my gratitude to my amazing development cohort, with whom it is my privilege to work. In particular, thanks are due to Michael Besosa, Karl Espe, David Gordhamer, Alok Gupta, Arun Lakkakula, Chad LaVigne, Vladan Pulec, Raghu Ramakrishnan, Giridhar Reddy, and Dan Syrstad. Your encouragement and support were invaluable to me. You guys are the best! I must also thank the talented team of developers who have contributed to the Apache Tomcat project. This product is truly an engineering marvel, and it was an instructive experience to rummage through its source. It is a credit to this team that the Tomcat mailing lists are not just civil places, but are also full of interesting tips and tricks, and well worth a visit. Finally, I'd like to acknowledge Joginder Nahil, who provided me with an early taste for the written word. This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 About the reviewers David O'Meara is an experienced developer, architect, and technical manager with over 10 years based in Australia and the USA. Primarily focusing on the Java language and related technologies, his experience is mainly based on web, distributed, and integration projects. He has previously worked on many business domains, but currently devotes the bulk of his time in the maintenance and programming of highly adaptive, semi-autonomous, self-aware bipedal hominids, also known as child raising. The rest of his spare time is often spent answering questions on the JavaRanch, moderating on DZone, or working on open source projects. Michael Besosa is a Principal Architect at Pearson VUE, Inc. Karl Espe and Alok Gupta are Web Engineering Leads at Pearson VUE, Inc. Arun Lakkakula and Giridhar Reddy are Senior Web Software Developers at Pearson VUE, Inc. David Gordhamer is a Web Software Developer at Pearson VUE, Inc. Chad LaVigne, Vladan Pulec, Raghu Ramakrishnan, and Dan Syrstad are web development consultants based in Minnesota. This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 This book is dedicated to: • My wife Devi, every day with you is a joy and a blessing • My children, Ashwin and Anita, you are the lights of my world • My parents, Nagarathnam and Shanmugam, who taught me all that is important This book would not have been possible without your love and understanding. Thank you from the bottom of my heart. This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 Table of Contents Preface 1 Chapter 1: Introduction to Tomcat 7 What's the story behind Tomcat? 8 What exactly is Tomcat? 9 JSPs 11 Servlet container 11 Why this book? 13 Gathering our tools 14 Java Development Kit (JDK) 6.0 15 Verifying downloaded files 15 Apache Ant 16 Subversion 17 Obtaining the Tomcat source code 18 Using Subversion 18 Tomcat source distribution 19 Getting ready to build Tomcat 19 Starting up your shiny new Tomcat 21 Eclipse 22 Summary 29 Chapter 2: Servlet API Overview 31 Java Community Process 31 Java Enterprise Edition platform 33 What is an enterprise application? 33 Simultaneous users 34 Highly available, reliable, and scalable 34 Heterogeneous environment 34 Distributed nature 35 Java EE architecture 36 Java based 37 Generic APIs 37 This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 Table of Contents Java EE containers and container services 38 Java EE components and their APIs 40 Java EE Service APIs 40 What is a typical Java EE application architecture? 42 Hypertext Transfer Protocol (HTTP) 43 Uniform Resource Locator, URL 45 HTTP methods 46 GET (HTTP/0.9) 46 POST (HTTP/1.0) 47 PUT (HTTP/1.1) 47 DELETE (HTTP/1.1) 47 TRACE (HTTP/1.1) 47 OPTIONS (HTTP/1.1) 47 HEAD (HTTP/1.0) 47 HTTP requests 48 HTTP responses 50 The response line 50 Response headers 51 Spying on HTTP 52 What is the Servlet API? 52 Servlet container 53 Core servlet classes 55 Servlets 56 ServletConfig interface 57 ServletContext interface 57 Multithreading in servlets 58 Request 60 Response 62 Sessions 64 Filters 64 Listeners 65 Web applications 66 Deployment descriptors 66 Summary 68 Chapter 3: Servlet Container Overview 69 Component taxonomy 71 Architectural benefits 73 Top Level Components 74 Server 74 Service 75 Connectors 76 Container components 78 Engine 78 Virtual host 79 Context 83 [ ii ] This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December 2009 6393 south jamaica court, , englewood, , 80111 Table of Contents Wrapper 85 Nested components 86 Valve 86 Realm 88 Executor 89 Listener 89 Manager 89 Loader 90
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages416 Page
-
File Size-