Thông tin tài liệu
MANNING
Hanumant Deshmukh
Jignesh Malavia
Matthew Scarpino
SCWCD
EXAM STUDY KIT
SECOND EDITION
JAVA WEB
COMPONENT
DEVELOPER
CERTIFICATION
SCE 310-081
www.it-ebooks.info
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 <tricia.fu@gmail.com>
www.it-ebooks.info
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
SCWCD
Exam Study Kit
Second Edition
JAVA WEB COMPONENT DEVELOPER CERTIFICATION
MATTHEW SCARPINO (Second Edition author)
H
ANUMANT DESHMUKH
JIGNESH MALAVIA
with Jacquelyn Carter
MANNING
Greenwich
(74° w. long.)
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
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: orders@manning.com
©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
12345678910–VHG–0908070605
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
v
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
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
vi BRIEF CONTENTS
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
CReview Q & A412
D Exam Quick Prep 475
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
vii
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
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
viii CONTENTS
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 an HttpServlet 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
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
CONTENTS ix
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 a web application 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
Licensed to Tricia Fu <tricia.fu@gmail.com>
www.it-ebooks.info
[...]... includes important packages, such as java. io, java. net, java. rmi, and javax.swing Sun offers two certifications for this platform: the Java Programmer (SCJP) certification and the Java Developer (SCJD) certification While the Java Programmer certification process consists of only one multiple-choice exam covering the basics of the Java language, the Java Developer certification requires you to develop a... Developer (SCWCD) certification, the Business Component Developer (SCBCD) certification, and the Enterprise Architect (SCEA) certification The SCWCD certification process is designed for programmers developing A roadmap for Sun’s certifications in the J2SE and the J2EE platforms SCJP certification is required before taking the SCWCD exam xix www.it-ebooks.info Licensed to Tricia Fu web. .. multiplechoice exam You must be a Sun Certified Java Programmer (SCJP) before you can take this exam The Business Component Developer certification is for developers creating applications with Enterprise JavaBeans (EJBs) and EJB containers The Enterprise Architect certification is designed for senior developers who are using the whole gamut of J2EE technologies to design enterprise-class applications The certification. .. Certified Web Component Developer (SCWCD) exam We had difficulty finding any books that thoroughly covered the objectives published by Sun The idea continued to percolate during the time we were developing JWebPlus, our exam simulator for the SCWCD With its successful release, we finally turned our attention to putting our combined knowledge and experience into this book We have been interacting with Java Certification. .. using the java. net, java. rmi, and javax.swing packages, followed by an essaytype exam on the application The Enterprise Edition (J2EE) builds on the Standard Edition and includes a number of technologies, such as Enterprise JavaBeans (EJB), Servlet, and JavaServer Pages, used for building enterprise-class server-side applications Sun offers three certifications for this platform: the Web Component Developer. .. 249 14 Using JavaBeans 251 14.1 JavaBeans: a brief overview 252 JavaBeans from the JSP perspective 252 ✦ The JavaBean advantage 253 ✦ Serialized JavaBeans 255 14.2 Using JavaBeans with JSP actions 258 Declaring JavaBeans using 258 ✦ Mutating properties using 266 ✦ Accessing properties using 269 14.3 JavaBeans in servlets 271 14.4 Accessing JavaBeans from... Certified Web Component Developer (SCWCD) exam, I thought it was going to be a breeze After all, I’d deployed some servlets and I had a solid working knowledge of JavaServer Pages ( JSPs) But before I registered, I figured a few simulation questions couldn’t hurt What an eye-opener! The questions seemed better suited to Trivial Pursuit than a software exam How could these sadists ask for every Java exception,... Sun certification exams The Java platform comes in three flavors: Standard Edition, Enterprise Edition, and Micro Edition The figure below shows the certification exams that Sun offers for the first two editions The Standard Edition (J2SE) is the basis of the Java platform and is used in the development of Java applets and applications The standard library includes important packages, such as java. io,... THE SUN CERTIFICATION EXAMS www.it-ebooks.info Licensed to Tricia Fu xxi about this book This book is built around the objectives that Sun has published for the updated SCWCD exam If you know everything that is covered by the objectives, you will pass the exam The chapters in the book examine each objective in detail and explain everything you need to understand about web component. .. courses on Java and web development, as well as C, C++, and Unix, at various locations, including the Narsee Monjee Institute of Management Science (NMIMS), Mumbai He has been actively involved with Enthuware projects and currently provides online guidance to candidates preparing for Sun certification exams MATTHEW SCARPINO is a Sun Certified Web Component Developer and has developed a number of web sites . Certified Web Component
Developer Certification (SCWCD) .”
— Focus on Java at About.com
“Certainly recommended for the web component developer examination. Deshmukh
Jignesh Malavia
Matthew Scarpino
SCWCD
EXAM STUDY KIT
SECOND EDITION
JAVA WEB
COMPONENT
DEVELOPER
CERTIFICATION
SCE 310-081
www.it-ebooks.info
Praise
Ngày đăng: 17/03/2014, 20:21
Xem thêm: Scwcd Exam Study Kit: Java Web Component Developer Certification pdf, Scwcd Exam Study Kit: Java Web Component Developer Certification pdf, 1 Sending requests: Web browsers and HTTP methods