ebook img

SCWCD Exam Study Kit: Java Web Component Developer Certification PDF

559 Pages·2005·4.528 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview SCWCD Exam Study Kit: Java Web Component Developer Certification

SCWCD SCE 310-081 EXAM STUDY KIT SECOND EDITION JAVA WEB COMPONENT DEVELOPER CERTIFICATION Hanumant Deshmukh Jignesh Malavia Matthew Scarpino M A N N I N G Praise for the First Edition “Written in a very easy-to-read, conversational tone and is an excellent resource for someone who’s familiar with Java but not with Servlets and JSPs or even for someone familiar with them, but who needs to brush up on some of the details for the exam … The bundled CD is chock-full of excellent resources … I will definitely use this book as a resource even after the exam.” — JavaRanch.com “If you want to buy just one book for the SCWCD exam, then this is the book to buy. The book is well-written and should act as a good reference for you.” — JavaPrepare.com “An excellent study guide highly recommended not only for SCWCD exam takers, but for anyone intending to put their exam credentials to good use … a solid reference for dedicated programmers.” — Internet Bookwatch Five stars! “Well written and well organized by folks who create testing software and mock exams. The Java source code examples are concise and illustrate the point well … The Bottom Line: A terrific study guide for the new Sun Certified Web Component Developer Certification (SCWCD).” — Focus on Java at About.com “Certainly recommended for the web component developer examination … extremely well organized and goes through each and every objective explaining the concepts in a lucid manner … this book avoids the hassles of going through any API’s or specs because of its thorough coverage. “… the discussion is thorough and not intimidating to a novice and even a beginner of web programming can digest the material easily. Overall I strongly recommend this book as a study guide for the examination and also as a general reference for JSP technology.” — Austin JUG “Like other Manning titles I've reviewed, this title is very dense with little fluff … indis- pensable if you are studying to earn this certification or just getting your feet wet in the web tier of Java technology … the perfect reference for the experienced developer who needs to learn the salient features of JSP/servlet technology quickly and without a lot of introductory ‘this is web programming’ fluff … it is a very thorough Servlet/JSP/Tag Library reference and developer guide.” — DiverseBooks.com “!!!! Exceptional!” — Today’s Books Licensed to Tricia Fu <[email protected]> Licensed to Tricia Fu <[email protected]> SCWCD Exam Study Kit Second Edition JAVA WEB COMPONENT DEVELOPER CERTIFICATION MATTHEW SCARPINO (Second Edition author) HANUMANT DESHMUKH JIGNESH MALAVIA with Jacquelyn Carter MANNING Greenwich (74° w. long.) Licensed to Tricia Fu <[email protected]> For online information and ordering of this and other Manning books, please go to www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. 209 Bruce Park Avenue Fax: (203) 661-9018 Greenwich, CT 06830 email: [email protected] ©2005 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. The authors and publisher have taken care in the preparation of this book, but make no express or implied warranty of any kind and assume no responsibility for errors or omissions. The authors and publisher assume no liability for losses or damages in connection with or resulting from the use of information or programs in the book and the accompanying downloads. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. Copyeditor: Liz Welch 209 Bruce Park Avenue Typesetter: D. Dalinnik Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN 1-932394-38-9 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – VHG – 09 08 07 06 05 Licensed to Tricia Fu <[email protected]> brief contents Part 1 Getting started 1 1 Understanding Java servlets 3 2 Understanding JavaServer Pages 14 3 Web application and HTTP basics 21 Part 2 Servlets 29 4 The servlet model 31 5 Structure and deployment 67 6 The servlet container model 83 7 Using filters 97 8 Session management 119 9 Developing secure web applications 139 Part 3 JavaServer Pages and design patterns 163 10 The JSP technology model—the basics 165 11 The JSP technology model—advanced topics 188 12 Reusable web components 219 v Licensed to Tricia Fu <[email protected]> 13 Creating JSPs with the Expression Language (EL) 236 14 Using JavaBeans 251 15 Using custom tags 285 16 Developing “Classic” custom tag libraries 309 17 Developing “Simple” custom tag libraries 352 18 Design patterns 376 Appendices A Installing Tomcat 5.0.25 403 B A sample web.xml file 408 C Review Q & A 412 D Exam Quick Prep 475 vi BRIEF CONTENTS Licensed to Tricia Fu <[email protected]> contents preface to the second edition xv preface to the first edition xvii acknowledgments xviii about the Sun certification exams xix about this book xxii about the authors xxv about the cover illustration xxvi Part 1 Getting started 1 1 Understanding Java servlets 3 1.1 What is a servlet? 4 Server responsibilities 4 ✦ Server extensions 5 1.2 What is a servlet container? 5 The big picture 5 ✦ Understanding servlet containers 5 Using Tomcat 8 1.3 Hello World servlet 8 The code 8 ✦ Compilation 9 ✦ Deployment 9 Execution 10 1.4 The relationship between a servlet container and the Servlet API 10 The javax.servlet package 10 ✦ The javax.servlet.http package 11 ✦ Advantages and disadvantages of the Servlet API 12 1.5 Summary 13 2 Understanding JavaServer Pages 14 2.1 What is a JSP page? 15 Server-side includes 15 vii Licensed to Tricia Fu <[email protected]> 2.2 Hello User 15 The HTML code 16 ✦ The servlet code 16 The JSP code 17 2.3 Servlet or JSP? 17 2.4 JSP architecture models 18 The Model 1 architecture 18 ✦ The Model 2 architecture 18 2.5 A note about JSP syntax 19 2.6 Summary 20 3 Web application and HTTP basics 21 3.1 What is a web application? 22 Active and passive resources 22 ✦ Web applications and the web application server 22 3.2 Understanding the HTTP protocol 23 HTTP basics 24 ✦ The structure of an HTTP request 24 The structure of an HTTP response 26 3.3 Summary 27 Part 2 Servlets 29 4 The servlet model 31 4.1 Sending requests: Web browsers and HTTP methods 32 Comparing HTTP methods 33 4.2 Handling HTTP requests in anHttpServlet 35 4.3 Analyzing the request 36 Understanding ServletRequest 37 ✦ Understanding HttpServletRequest 37 4.4 Sending the response 40 Understanding ServletResponse 40 ✦ Understanding HttpServletResponse 43 4.5 Servlet life cycle 45 Loading and instantiating a servlet 46 ✦ Initializing a servlet 46 Servicing client requests 47 ✦ Destroying a servlet 48 Unloading a servlet 48 ✦ Servlet state transition from the servlet container’s perspective 48 4.6 ServletConfig: a closer look 50 ServletConfig methods 50 ✦ Example: a servlet and its deployment descriptor 50 4.7 ServletContext: a closer look 53 viii CONTENTS Licensed to Tricia Fu <[email protected]> 4.8 Beyond servlet basics 54 Sharing the data (attribute scopes) 55 ✦ Coordinating servlets using RequestDispatcher 57 ✦ Accessing request-scoped attributes with RequestDispatcher 58 ✦ Putting it all together: A simple banking application 59 4.9 Summary 63 4.10 Review questions 63 5 Structure and deployment 67 5.1 Directory structure of awebapplication 68 Understanding the document root directory 68 ✦ Understanding the WEB-INF directory 69 ✦ The web archive (WAR) file 70 Resource files and HTML access 70 ✦ The default web application 71 5.2 The deployment descriptor: an overview 71 Example: A simple deployment descriptor 72 ✦ Using the <servlet> element 73 ✦ Using the <servlet-mapping> element 75 ✦ Mapping a URL to a servlet 76 5.3 Summary 80 5.4 Review questions 80 6 The servlet container model 83 6.1 Initializing ServletContext 84 6.2 Adding and listening to scope attributes 85 Adding and removing scope attributes 85 ✦ Listening to attribute events 86 6.3 Servlet life-cycle events and listeners 88 javax.servlet.ServletContextListener 88 javax.servlet.Http.HttpSessionListener 89 javax.servlet.Http.HttpServletRequestListener 89 6.4 Adding listeners in the deployment descriptor 90 6.5 Web applications in a distributed environment 92 Behavior of a ServletContext 92 ✦ Behavior of an HttpSession 93 6.6 Summary 94 6.7 Review questions 94 7 Using filters 97 7.1 What is a filter? 98 How filtering works 99 ✦ Uses of filters 99 ✦ The Hello World filter 100 CONTENTS ix Licensed to Tricia Fu <[email protected]>

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.