SCWCD Exam Study Kit: Java Web Component Developer Certification, 2/e (Paperback)

Hanumant Deshmukh, Jignesh Malavia, Matthew Scarpino

下單後立即進貨 (2~3週)

買這商品的人也買了...

商品描述

Description:

With the tremendous penetration of J2EE in the enterprise, passing the Sun Certified Web Component Developer exam has become an important qualification for Java and J2EE developers. To pass the SCWCD exam (Number: 310-081) you need to answer 69 questions in 135 minutes and get 62% of them right. You also need $150 and this (completely updated and newly revised) book.

In its first edition, the SCWCD Exam Study Kit was the most popular book used to pass this most desirable web development certification exam. The new edition will help you learn the concepts—large and small—that you need to know. It covers the newest version of the exam and not a single topic is missed.

The SCWCD exam is for Sun Certified Java Programmers who have a certain amount of experience with Servlets and JSPs, but for those who do not, the book starts with three introductory chapters on these topics. Although the SCWCD Exam Study Kit has one purpose, to help you get certified, you will find yourself returning to it as a reference after passing the exam.

 

Table of 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
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
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
7.2 The Filter API 102
The Filter interface 103
The FilterConfig interface 105
The FilterChain interface 105
The request and response wrapper classes 106
7.3 Configuring a filter 106
The <filter> element 106
The <filter-mapping> element 107
Configuring a filter chain 107
7.4 Advanced features 110
Using the request and response wrappers 110
Important points to remember about filters 116
Using filters with MVC 116
7.5 Summary 117
7.6 Review questions 117
8  Session management   119
8.1 Understanding state and sessions 120
8.2 Using HttpSession 121
Working with an HttpSession 122
Handling session events with listener interfaces 124
Invalidating a Session 130
8.3 Understanding session timeout 130
8.4 Implementing session support 131
Supporting sessions using cookies 132
Supporting sessions using URL rewriting 133
8.5 Summary 136
8.6 Review questions 136
9  Developing secure web applications   139
9.1 Basic concepts 140
Authentication 140
Authorization 140
Data integrity 141
Confidentiality or data privacy 141
Auditing 141
Malicious code 141
Web site attacks 141
9.2 Understanding authentication mechanisms 142
HTTP Basic authentication 143
HTTP Digest authentication 145
HTTPS Client authentication 145
FORM-based authentication 146
Defining authentication mechanisms for web applications 146
9.3 Securing web applications declaratively 149
display-name 149
web-resource-collection 149
auth-constraint 150
user-data-constraint 151
Putting it all together 152
9.4 Securing web applications programmatically 156
9.5 Summary 158
9.6 Review questions 159

Part 3  JavaServer Pages and Design Patterns   163

10  The JSP technology model—the basics   165
10.1 SP syntax elements 166
Directives 167
Declarations 168
Scriptlets 169
Expressions 170
Actions 171
Comments 172
10.2 The JSP page life cycle 173
JSP pages are servlets 174
Understanding translation units 174
JSP life-cycle phases 175
JSP life-cycle example 178
10.3 Understanding JSP page directive attributes 181
The import attribute 182
The session attribute 182
The errorPage and isErrorPage attributes 182
The language and extends attributes 184
The buffer and autoFlush attributes 184
The info attribute 185
The contentType and pageEncoding attributes 185
10.4 Summary 186
10.5 Review questions 186
11  The JSP technology model—advanced topics   188
11.1 Understanding the translation process 189
Using scripting elements 189
Using conditional and iterative statements 191
Using request-time attribute expressions 194
Using escape sequences 194
11.2 Understanding JSP implicit variables and JSP implicit objects 198
application 200
session 201
request and response 202
page 202
pageContext 202
out 203
config 204
exception 206
11.3 Understanding JSP page scopes 207
Application scope 207
Session scope 207
Request scope 208
Page scope 209
11.4 JSP pages as XML documents 211
The root element 212
Directives and scripting elements 213
Text, comments, and actions 214
11.5 Summary 215
11.6 Review questions 216
12  Reusable web components   219
12.1 Static inclusion 220
Accessing variables from the included page 221
Implications of static inclusion 222
12.2 Dynamic inclusion 223
Using jsp:include 223
Using jsp:forward 225
Passing parameters to dynamically included components 226
Sharing objects with dynamically included components 228
12.3 Summary 232
12.4 Review questions 232
13  Creating JSPs with the Expression Language (EL)   236
13.1 Understanding the Expression Language 237
EL expressions and JSP script expressions 237
Using implicit variables in EL expressions 238
13.2 Using EL operators 241
EL operators for property and collection access 241
EL arithmetic operators 242
EL relational and logical operators 243
13.3 Incorporating functions with EL 244
Creating the static methods 244
Creating a tag library descriptor (TLD) 245
Modifying the deployment descriptor 246
Accessing EL functions within a JSP 247
13.4 Summary 249
13.5 Review questions 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 <jsp:useBean> 258
Mutating properties using <jsp:setProperty> 266
Accessing properties using <jsp:getProperty> 269
14.3 JavaBeans in servlets 271
14.4 Accessing JavaBeans from scripting elements 274
14.5 More about properties in JavaBeans 276
Using nonstring data type properties 276
Using indexed properties 278
14.6 Summary 280
14.7 Review questions 281
15  Using custom tags   285
15.1 Getting started 286
New terms 286
Understanding tag libraries 287
15.2 Informing the JSP engine about a custom tag library 288
Location of a TLD file 289
Associating URIs with TLD file locations 290
Understanding explicit mapping 290
Resolving URIs to TLD file locations 291
Understanding the prefix 293
15.3 Using custom tags in JSP pages 293
Empty tags 294
Tags with attributes 295
Tags with JSP code 296
Tags with nested custom tags 297
15.4 Using the JSP Standard Tag Library (JSTL) 298
Acquiring and installing the JSTL 298
General purpose JSTL tags: <c:catch> and <c:out> 299
Variable support JSTL tags: <c:set> and <c:remove> 300
Flow control JSTL: <c:if>, <c:choose>, <c:forEach>, and <c:forTokens> 301
15.5 Summary 305
15.6 Review questions 305
16  Developing “Classic” custom tag libraries   309
16.1 Understanding the tag library descriptor 310
The <taglib> element 311
The <tag> element 313
The <attribute> element 314
The <body-content> element 316
16.2 The Tag Extension API 318
16.3 Implementing the Tag interface 320
Understanding the methods of the Tag interface 321
An empty tag that prints HTML text 324
An empty tag that accepts an attribute 326
A nonempty tag that includes its body content 328
16.4 Implementing the IterationTag interface 329
Understanding the IterationTag methods 329
A simple iterative tag 330
16.5 Implementing the BodyTag interface 333
Understanding the methods of BodyTag 334
A tag that processes its body 335
16.6 Extending TagSupport and BodyTagSupport 338
The TagSupport class 338
The BodyTagSupport class 339
Accessing implicit objects 339
Writing cooperative tags 343
16.7 What’s more? 347
16.8 Summary 348
16.9 Review questions 349
17  Developing “Simple” custom tag libraries   352
17.1 Understanding SimpleTags 353
A brief example 353
Exploring SimpleTag and SimpleTagSupport 354
17.2 Incorporating SimpleTags in JSPs 357
Coding empty SimpleTags 357
Adding dynamic attributes to SimpleTags 359
Processing body content inside SimpleTags 362
17.3 Creating Java-free libraries with tag files 364
Introducing tag files 364
Tag files and TLDs 365
Controlling tag processing with tag file directives 366
Processing fragments and body content with tag file actions 368
17.4 Summary 371
17.5 Review questions 372
18  Design patterns   376
18.1 Design patterns: a brief history 377
The civil engineering patterns 377
The Gang of Four patterns 377
The distributed design patterns 379
The J2EE patterns 379
18.2 Patterns for the SCWCD exam 382
The pattern template 382
The Intercepting Filter 385
Model-View-Controller (MVC) 386
Front Controller 389
Service Locator 391
Business Delegate 393
Transfer Object 397
18.3 Summary 400
18.4 Review questions 401
A  Installing Tomcat 5.0.25   403
B  A sample web.xml file   408
C  Review Q & A   412
D  Exam Quick Prep   475

index 523