1. Trang chủ
  2. » Công Nghệ Thông Tin

Apress professional java servlets 2 3 jan 2002 ISBN 186100561x

1,2K 60 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.213
Dung lượng 7,55 MB

Nội dung

Professional Java Servlets 2.3 ISBN:186100561X by Andrew HarbourneThomas et al APress, LLC © 2004 (700 pages) For Java programmers who are moving into working with J2EE components and want to learn how to apply their skills to create real-world web components, this guide has it all! Table of Contents Professional Java Servlets 2.3 Introduction Chapter 1 - Servlets in the Enterprise Chapter 2 - The Servlet 2.3 API Chapter 3 - HTTP Servlets Deploying Web Chapter 4 Applications Chapter 5 - Session Handling Servlet Persistence and Chapter 6 Resources Chapter 7 - Filters Chapter 8 - JavaServer Pages Chapter 9 - Security and Container Authentication Servlet Debugging Chapter 10 Techniques Class Loading and Chapter 11 Synchronization Designing Web Chapter 12 - Applications and Servlet Patterns Performance and Chapter 13 Scalability Web Services and Servlet Chapter 14 Agents Appendix A - Installing Tomcat 4.0 Appendix B - HTTP Reference Appendix C - Servlet 2.3 API Reference Back Cover Java servlets are fast becoming indispensable enterprise components, as they provide a means to build scalable and portable business services that communicate over the Web This book provides a comprehensive guide to developing applications based on the Java Servlet 2.3 API, a part of the Java 2 Platform, Enterprise Edition 1.3 The book reveals how and where servlets fit into an enterprise solution, and addresses issues such as security, scalability, performance and design It walks you through the API covering the role of all the classes and interfaces and provides lots of example applications to demonstrate servlets in action The book also covers the key role that servlets play in the new web services development model What does this book cover? The servlet container and the services it provides Creating and deploying web applications in Tomcat Persisting the state of servlets Filters and Event Listeners Security and Container Authentication Debugging servlets The effects of classloading and synchronization on the behavior of web applications Optimizing the performance of web applications Using servlets as agents with web services Professional Java Servlets 2.3 Subrahmanyam Allamaraju John T Bell Simon Brown Sam Dalton Andrew Harbourne-Thomas Bjarki Holm Meeraj Moidoo Kunnumpurath Sing Li Tony Loton Copyright © 2004 by Apress (This book was originally published by Wrox Press in 2002.) All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN (pbk): 1-861005-61-X Printed and bound in the United States of America 10987654321 Trademarked names may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY, 10010 and outside the United States by Springer-Verlag GmbH & Co KG, Tiergartenstr 17, 69112 Heidelberg, Germany In the United States: phone 1-800-SPRINGER, email , or visit http://www.springerny.com Outside the United States: fax +49 6221 345229, email , or visit http://www.springer.de For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710 Phone 510-549-5930, fax 510-549-5939, email , or visit http://www.apress.com The information in this book is distributed on an "as is" basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work The source code for this book is available to readers at http://www.apress.com in the Downloads section Credits Authors Subrahmanyam Allamaraju John T Bell Simon Brown Sam Dalton Andrew Harbourne-Thomas Bjarki Holm Meeraj Kunnumpurath Technical Architect Craig A Berry Technical Reviewers Kapil Apshankar Steve Baker Richard Bonneau Jeff Cunningham Sam Dalton Cosmo Di Fazio Justin Foley Phil Hanna Anne Horton Graham Innocent Dan Jepp Technical Editors Tabasam Haseen Christian Peak Daniel Richardson Steve Rycroft Category Manager Emma Batch Author Agent Velimir Ilic Project Administrators Laura Hall Claire Robinson Christianne Bailey Tony Loton Vinay Menon Rick Moore Navaneeth Krishnan Stéphane Osmont Sumit Pal Phil Powers-DeGeorge Trent Rosenbaum Keyur Shah Production Coordinator Tom Bartlett Illustrations Cover Proof Reader Index John Collin About the Authors Subrahmanyam Allamaraju Subrahmanyam is a Senior Engineer with BEA Systems His interest in modeling lead him from his Ph.D in Electrical Engineering to objectoriented programming, and then to distributed computing and software architecture In this process, he drifted from his one-time home - the Indian Institute of Technology, to Computervision, and Wipro Infotech, and later to BEA Systems You can find more about his current activities at his home http://www.Subrahmanyam.com Subrahmanyam would like to thank Varaa for her hand in code samples (in the face of tight deadlines), and sharing his frustration as well as exhilaration Subrahmanyam contributed Chapter 5 to this book John T Bell John Bell is a Principal Engineer at Latitude360, a subsidiary of RWD Technologies He has been providing technology solutions for over 20 years and has been developing Java-based web systems for the past several years His primary areas of expertise are in object-oriented development and distributed processing systems Recently he has been supporting DaimlerChrysler as lead architect for a number of Java-based web platform initiatives He is now supporting Latitde360's own eLearning product development efforts He has a Bachelor's degree in Electrical Engineering and a Masters degree in Computer Systems Management, both from the University of Maryland In his spare time he plays with his kids, maintains computers for local charities, and writes strategy based computer games He is also active in the Christian and Missionary Alliance Church Many thanks to Latitude360 and RWD Technologies for providing me with the time, equipment, and software needed to work on this book Dedicated to my parents, my mother who gave me the gift of writing and my father who introduced me to electronics, computers, and engineering John contributed Chapter 14 to this book Simon Brown Simon is a Technical Architect working in London and has been using Java since 1996 During this time he has been involved with many Java developments, acting as technical lead, mentor and trainer Outside of work he has spoken at several Java events, including JavaOne, has been published on JavaWorld and co-authored the 2nd Edition of Professional JSP Simon graduated from the University of Reading in 1996 with a First Class BSc (Hons) degree in Computer Science He has also attained many Sun certifications, including the Sun Certified Enterprise Architect for J2EE, Web Component Developer for J2EE and Developer for the Java 2 Platform Feel free to e-mail any questions or comments to I would once again like to thank my fiancée Kirstie for her encouragement, and also for putting up with me being tucked away in the spare room for hours at a time Simon contributed Chapter 12 to this book Sam Dalton Sam is a Technical Architect, and is based in London He has worked with Java and related technologies for a number of years, in various industries, including investment banking, insurance, and retail ecommerce Sam was fortunate enough to present and co-present several very popular sessions at JavaOne in 2001, and hopes to make many more appearances in the future Sam graduated from The University of Reading, with an honors degree in Computer Science, and is now a Sun Certified Programmer, Developer, and Web Component Developer for the Java 2 platform Many heartfelt thanks go to my wife Anne, who is always very supportive of my efforts, and always there with a nice cup of tea! Sam contributed Chapter 4 to this book Andrew Harbourne-Thomas Andrew Harbourne-Thomas is an independent consultant focusing on J2EE application design and development and project management He started working life as an economist, worked as Economic Advisor to the Irish Trade Board (now Enterprise Ireland), followed by several years working as an independent consultant to top companies including Microsoft, focusing on technology, strategy and project management He was always interested in evolving technologies and has been working with Java technologies since 1997, including some time with Bear Stearns IT division His main interests include J2EE application architecture, web service design, extreme programming, and emerging technologies Andrew lives in Dublin, Ireland, and while escaping from Java; his main pursuits include scuba diving and photography Thank you Miriam for your love, patience and support Andrew contributed Chapters 1-3 and Appendix B to this book Bjarki Holm For the past five years, Bjarki has been working at software engineering at VYRE Corporation in Reykjavík, developing on-line design and content management systems using servlets with an Oracle backend Currently, he is taking time off from work to pursue his studies of electrical engineering and occasional writing opportunities Bjarki contributed Chapter 6 to this book getAttributeNames() method, HttpSession interface, 33 getAttributeNames() method, ServletRequest interface, 10 getAuthType() method, HttpServletRequest interface, 25 getBufferSize() method, ServletResponse interface, 15 getCharacterEncoding() method, ServletRequest interface, 10 getCharacterEncoding() method, ServletResponse interface, 14 getComment() method, Cookie class, 37 getContentLength() method, ServletRequest interface, 11 getContentType() method, ServletRequest interface, 11 getContext() method, ServletContext interface, 6 getContextPath() method, HttpServletRequest interface, 26 getCookies() method, HttpServletRequest interface, 25 getCreationTime() method, HttpSession interface, 32 getDateHeader() method, HttpServletRequest interface, 25 getDomain() method, Cookie class, 37 getFilterConfig() method, Filter interface, 2 getFilterName() method, FilterConfig interface, 3 getHeader() method, HttpServletRequest interface, 25 getHeaderNames() method, HttpServletRequest interface, 26 getHeaders() method, HttpServletRequest interface, 25 getId() method, HttpSession interface, 32 getIds() method, HttpServletRequest interface, 36 getInitParameter() method, FilterConfig interface, 3 getInitParameter() method, GenericServlet class, 17 getInitParameter() method, ServletConfig interface, 5 getInitParameter() method, ServletContext interface, 7 getInitParameterNames() method, 8 getInitParameterNames() method, FilterConfig interface, 3 getInitParameterNames() method, GenericServlet class, 17 getInitParameterNames() method, ServletConfig interface, 5 getInputStream() method, ServletRequest interface, 11 getIntHeader() method, HttpServletRequest interface, 26 getLastAccessedTime() method, HttpSession interface, 32 getLastModified() method, HttpServlet class, 41 getLocale() method, ServletRequest interface, 13 getLocale() method, ServletResponse interface, 16 getLocales() method, ServletRequest interface, 13 getMajorVersion() method, ServletContext interface, 6 getMaxAge() method, Cookie class, 38 getMaxInactiveInterval() method, HttpSession interface, 33 getMethod() method, HttpServletRequest interface, 26 getMimeType() method, ServletContext interface, 6 getMinorVersion() method, ServletContext interface, 6 getName method, HttpSessionBindingEvent class, 44 getName() method, Cookie class, 38 getName() method, ServletContextAttributeEvent class, 18 getNamedDispatcher() method, ServletContext interface, 7 getOutputStream() method, ServletResponse interface, 14 getParameter() method, ServletRequest interface, 11 getParameterMap() method, ServletRequest interface, 12 getParameterNames() method, ServletRequest interface, 11 getParamterValues() method, ServletRequest interface, 11 getPath() method, Cookie class, 38 getPathInfo() method, HttpServletRequest interface, 26 getPathTranslated() method, HttpServletRequest interface, 26 getProtocol() method, ServletRequest interface, 12 getQueryString() method, HttpServletRequest interface, 27 getReader() method, ServletRequest interface, 12 getRealPath() method, ServletContext interface, 7 getRealPath() method, ServletRequest interface, 14 getRemoteAddr() method, ServletRequest interface, 12 getRemoteHost() method, ServletRequest interface, 13 getRemoteUser() method, HttpServletRequest interface, 27 getRequest() method, ServletRequestWrapper class, 21 getRequestDispatcher() method, ServletContext interface, 7 getRequestDispatcher() method, ServletRequest interface, 13 getRequestedSessionId() method, HttpServletRequest interface, 27 getRequestURI() method, HttpServletRequest interface, 27 getRequestURL() method, HttpServletRequest interface, 27 getResource() method, ServletContext interface, 6 getResourceAsStream() method, ServletContext interface, 7 getResourcePaths() method, ServletContext interface, 6 getResponse() method, ServletResponseWrapper class, 22 getRootCause() method, ServletException exception class, 23 getScheme() method, ServletRequest interface, 12 getSecure() method, Cookie class, 38 getServerInfo() method, ServletContext interface, 7 getServerName() method, ServletRequest interface, 12 getServerPort() method, ServletRequest interface, 12 getServlet() method, ServletContext interface, 9 getServletConfig() method, GenericServlet class, 17 getServletConfig() method, Servlet interface, 4 getServletContext() method, FilterConfig interface, 3 getServletContext() method, GenericServlet class, 17 getServletContext() method, ServletConfig interface, 5 getServletContext() method, ServletContextEvent class, 19 getServletContextName() method, ServletContext interface, 8 getServletInfo() method, GenericServlet class, 17 getServletInfo() method, Servlet interface, 4 getServletName() method, GenericServlet class, 18 getServletName() method, ServletConfig interface, 5 getServletNames() method, ServletContext interface, 9 getServletPath() method, HttpServletRequest interface, 28 getServlets() method, ServletContext interface, 9 getSession method, HttpSessionEvent class, 44 getSession() method, 36 getSession() method, HttpServletRequest interface, 28 getSession() method, HttpSessionContext interface, 36 getSessionContext() method, HttpSession interface, 34 getUnavailableSeconds() method, UnavailableException exception class, 24 getUserPrincipal() method, HttpServletRequest interface, 27 getValue method, HttpSessionBindingEvent class, 44 getValue() method, Cookie class, 39 getValue() method, HttpSession interface, 34 getValue() method, ServletContextAttributeEvent class, 18 getValueNames() method, HttpSession interface, 34 getVersion() method, Cookie class, 39 getWriter() method, ServletResponse interface, 14 include() method, RequestDispatcher interface, 4 init() method, GenericServlet class, 16, 17 init() method, Servlet interface, 4 invalidate() method, HttpSession interface, 33 isCommitted() method, ServletResponse interface, 15 isNew() method, HttpSession interface, 33 isPermanent() method, UnavailableException exception class, 24 isRequestedSessionIdFromCookie() method, HttpServletRequest interface, 28 isRequestedSessionIdFromURL() method, HttpServletRequest interface, 28 isRequestedSessionIdValid() method, HttpServletRequest interface, 28 isSecure() method, ServletRequest interface, 13 isUserInRole() method, HttpServletRequest interface, 27 log() method, GenericServlet class, 18 log() method, ServletContext interface, 7, 9 print() method, ServletOutputStream class, 20 println() method, ServletOutputStream class, 20 putValue() method, HttpSession interface, 34 readLine() method, ServletInputStream class, 19 removeAttribute() method, 8 removeAttribute() method, HttpSession interface, 33 removeAttribute() method, ServletRequest interface, 13 removeValue() method, HttpSession interface, 34 reset() method, ServletResponse interface, 15 resetBuffer() method, ServletResponse interface, 15 sendError() method, HttpServletResponse interface, 30 sendRedirect() method, HttpServletResponse interface, 30 service() method, GenericServlet class, 18 service() method, HttpServlet class, 41 service() method, Servlet interface, 4 servicegetSession method, HttpSessionBindingEvent class, 43 sessionCreated() method, HttpSessionListener interface, 36 sessionDestroyed() method, HttpSessionListener interface, 36 sessionDidActivate() method, HttpSessionActivationListener interface, 34 sessionDidActivate() method, HttpSessionAttributesListener interface, 35 sessionWillPassivate() method, HttpSessionActivationListener interface, 34 setAttribute() method, HttpSession interface, 33 setAttribute() method, ServletContext interface, 8 setAttribute() method, ServletRequest interface, 13 setBufferSize() method, ServletResponse interface, 15 setCharacterEncoding() method, ServletRequest interface, 11 setComment() method, Cookie class, 37 setContentLength() method, ServletResponse interface, 14 setContentType() method, ServletResponse interface, 15 setDateHeader() method, HttpServletResponse interface, 30 setDomain() method, Cookie class, 37 setFilterConfig() method, Filter interface, 2 setHeader() method, HttpServletResponse interface, 31 setIntHeader() method, HttpServletResponse interface, 31 setLocale() method, ServletResponse interface, 16 setMaxAge() method, Cookie class, 38 setMaxInactiveInterval() method, HttpSession interface, 32 setPath() method, Cookie class, 38 setRequest() method, ServletRequestWrapper class, 21 setResponse() method, ServletResponseWrapper class, 22 setSecure() method, Cookie class, 38 setStatus() method, HttpServletResponse interface, 31, 32 setValue() method, Cookie class, 38 setVersion() method, Cookie class, 39 valueBound() method, HttpSessionBindingListener interface, 35 valueUnbound() method, HttpSessionBindingListener interface, 35 P packages javax.servlet package, 1-24 javax.servlet.http package, 24-44 print() method, ServletOutputStream class appendix - servlet 2.3 API reference, 20 println() method, ServletOutputStream class appendix - servlet 2.3 API reference, 20 putValue() method, HttpSession interface appendix - servlet 2.3 API reference, 34 R readLine() method, ServletInputStream class appendix - servlet 2.3 API reference, 19 removeAttribute() method, HttpSession interface appendix - servlet 2.3 API reference, 33 removeAttribute() method, ServletContext interface appendix - servlet 2.3 API reference, 8 removeAttribute() method, ServletRequest interface appendix - servlet 2.3 API reference, 13 removeValue() method, HttpSession interface appendix - servlet 2.3 API reference, 34 RequestDispatcher interface, javax.servlet appendix - servlet 2.3 API reference, 3 foward() method, 3 include() method, 4 reset() method, ServletResponse interface appendix - servlet 2.3 API reference, 15 resetBuffer() method, ServletResponse interface appendix - servlet 2.3 API reference, 15 S sendError() method, HttpServletResponse interface appendix - servlet 2.3 API reference, 30 sendRedirect() method, HttpServletResponse interface appendix - servlet 2.3 API reference, 30 service() method, GenericServlet class appendix - servlet 2.3 API reference, 18 service() method, HttpServlet class appendix - servlet 2.3 API reference, 41 service() method, Servlet interface appendix - servlet 2.3 API reference, 4 servicegetSession method, HttpSessionBindingEvent class appendix - servlet 2.3 API reference, 43 Servlet 2.3 API reference appendix, 1 Servlet interface, javax.servlet appendix - servlet 2.3 API reference, 4 destroy() method, 5 getServletConfig() method, 4 getServletInfo() method, 4 init() method, 4 service() method, 4 ServletConfig interface, javax.servlet appendix - servlet 2.3 API reference, 5 getInitParameter() method, 5 getInitParameterNames() method, 5 getServletContext() method, 5 getServletName() method, 5 ServletContext interface, javax.servlet appendix - servlet 2.3 API reference, 6 deprecated methods, 9 ServletContextAttributeEvent class, javax.servlet appendix - servlet 2.3 API reference, 18 getName() method, 18 getValue() method, 18 ServletContextAttributesListener interface, javax.servlet appendix - servlet 2.3 API reference, 9 ServletContextEvent class, javax.servlet appendix - servlet 2.3 API reference, 19 getServletContext() method, 19 ServletContextListener interface, javax.servlet appendix - servlet 2.3 API reference, 10 ServletException exception class, javax.servlet getRootCause() method, 23 ServletException exception, javax.servlet appendix - servlet 2.3 API reference, 23 ServletInputStream class, javax.servlet appendix - servlet 2.3 API reference, 19 readLine() method, 19 ServletOutputStream class, javax.servlet appendix - servlet 2.3 API reference, 20 getRequest() method, 21 getResponse() method, 22 print() method, 20 println() method, 20 setRequest() method, 21 setResponse() method, 22 ServletRequest interface, javax.servlet appendix - servlet 2.3 API reference, 10 deprecated method, 14 ServletRequestWrapper class, javax.servlet !see also wrapped ServletRequest classes, 22 appendix - servlet 2.3 API reference, 21 overridden methods, 22 ServletResponse interface, javax.servlet appendix - servlet 2.3 API reference, 14 ServletResponseWrapper class, javax.servlet !see also wrapped ServletResponse methods, 23 appendix - servlet 2.3 API reference, 22 overridden methods, 23 sessionCreated() method, HttpSessionListener interface appendix - servlet 2.3 API reference, 36 sessionDestroyed() method, HttpSessionListener interface appendix - servlet 2.3 API reference, 36 sessionDidActivate() method, HttpSessionActivationListener interface appendix - servlet 2.3 API reference, 34 sessionWillPassivate() method, HttpSessionActivationListener interface appendix - servlet 2.3 API reference, 34 setAttribute() method, HttpSession interface appendix - servlet 2.3 API reference, 33 setAttribute() method, ServletContext interface appendix - servlet 2.3 API reference, 8 setAttribute() method, ServletRequest interface appendix - servlet 2.3 API reference, 13 setBufferSize() method, ServletResponse interface appendix - servlet 2.3 API reference, 15 setCharacterEncoding() method, ServletRequest interface appendix - servlet 2.3 API reference, 11 setComment() method, Cookie class appendix - servlet 2.3 API reference, 37 setContentLength() method, ServletResponse interface appendix - servlet 2.3 API reference, 14 setContentType() method, ServletResponse interface appendix - servlet 2.3 API reference, 14 setDateHeader() method, HttpServletResponse interface appendix - servlet 2.3 API reference, 30 setDomain() method, Cookie class appendix - servlet 2.3 API reference, 37 setFilterConfig() method, Filter interface appendix - servlet 2.3 API reference, 2 setHeader() method, HttpServletResponse interface appendix - servlet 2.3 API reference, 31 setIntHeader() method, HttpServletResponse interface appendix - servlet 2.3 API reference, 31 setLocale() method, ServletResponse interface appendix - servlet 2.3 API reference, 16 setMaxAge() method, Cookie class appendix - servlet 2.3 API reference, 38 setMaxInactiveInterval() method, HttpSession interface appendix - servlet 2.3 API reference, 32 setPath() method, Cookie class appendix - servlet 2.3 API reference, 38 setRequest() method, ServletRequestWrapper class appendix - servlet 2.3 API reference, 21 setResponse() method, ServletResponseWrapper class appendix - servlet 2.3 API reference, 22 setSecure() method, Cookie class appendix - servlet 2.3 API reference, 38 setStatus() method, HttpServletResponse interface appendix - servlet 2.3 API reference, 31, 32 setValue() method, Cookie class appendix - servlet 2.3 API reference, 38 setVersion() method, Cookie class appendix - servlet 2.3 API reference, 39 SingleThreadModel interface, javax.servlet appendix - servlet 2.3 API reference, 16 U UnavailableException exception class, javax.servlet deprecated constructors and method, 24 getUnavailableSeconds() method, 24 isPermanent() method, 24 UnavailableException exception, javax.servlet appendix - servlet 2.3 API reference, 23 V valueBound() method, HttpSessionBindingListener interface appendix - servlet 2.3 API reference, 35 valueUnbound() method, HttpSessionBindingListener interface appendix - servlet 2.3 API reference, 36 ... However, in this book we're going to concern ourselves with Java 2 Platform, Enterprise Edition (J2EE) In fact we're going to concentrate on one part of J2EE - the Java Servlet 2. 3 API J2EE builds upon J2SE, providing APIs and services for developing and... New classes and method changes and deprecation of the javax.servlet.http.HttpUtils class The Servlets 2. 3 API specification is also a key component in the Java 2 Patform, Enterprise Edition (J2EE) 1 .3 specification, and as we will see in... comprehensive guide to developing applications based on the Java Servlet 2. 3 API, a part of the Java 2 Platform, Enterprise Edition 1 .3 The book reveals how and where servlets fit into an enterprise solution, and addresses issues such as

Ngày đăng: 26/03/2019, 16:28