SCWCD Exam Study Kit: Java Web Component Developer Certification [2nd ed.] 1932394389, 9781932394382

Aimed at helping Java developers, Servlet/JSP developers, and J2EE developers pass the Sun Certified Web Component Devel

263 43 3MB

English Pages 559 Year 2005

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
contents......Page 8
preface to the second edition......Page 16
preface to the first edition......Page 18
acknowledgments......Page 19
about the Sun certification exams......Page 20
about this book......Page 23
about the authors......Page 26
about the cover illustration......Page 27
Part 1 - Getting started......Page 28
Understanding Java servlets......Page 30
1.1.1 Server responsibilities......Page 31
1.2.2 Understanding servlet containers......Page 32
1.3.1 The code......Page 35
1.3.3 Deployment......Page 36
1.4.1 The javax.servlet package......Page 37
1.4.2 The javax.servlet.http package......Page 38
1.4.3 Advantages and disadvantages of the Servlet API......Page 39
1.5 Summary......Page 40
Understanding JavaServer Pages......Page 41
2.2 Hello User......Page 42
2.2.2 The servlet code......Page 43
2.3 Servlet or JSP?......Page 44
2.4.2 The Model 2 architecture......Page 45
2.5 A note about JSP syntax......Page 46
2.6 Summary......Page 47
Web application and HTTP basics......Page 48
3.1.2 Web applications and the web application server......Page 49
3.2 Understanding the HTTP protocol......Page 50
3.2.2 The structure of an HTTP request......Page 51
3.2.3 The structure of an HTTP response......Page 53
3.3 Summary......Page 54
Part 2 - Servlets......Page 56
The servlet model......Page 58
4.1 Sending requests: Web browsers and HTTP methods......Page 59
4.1.1 Comparing HTTP methods......Page 60
4.2 Handling HTTP requests in an HttpServlet......Page 62
4.3 Analyzing the request......Page 63
4.3.2 Understanding HttpServletRequest......Page 64
4.4.1 Understanding ServletResponse......Page 67
4.4.2 Understanding HttpServletResponse......Page 70
4.5 Servlet life cycle......Page 72
4.5.2 Initializing a servlet......Page 73
4.5.3 Servicing client requests......Page 74
4.5.6 Servlet state transition from the servlet container’s perspective......Page 75
4.6.2 Example: a servlet and its deployment descriptor......Page 77
4.7 ServletContext: a closer look......Page 80
4.8 Beyond servlet basics......Page 81
4.8.1 Sharing the data (attribute scopes)......Page 82
4.8.2 Coordinating servlets using RequestDispatcher......Page 84
4.8.3 Accessing request-scoped attributes with RequestDispatcher......Page 85
4.8.4 Putting it all together: A simple banking application......Page 86
4.10 Review questions......Page 90
Structure and deployment......Page 94
5.1.1 Understanding the document root directory......Page 95
5.1.2 Understanding the WEB-INF directory......Page 96
5.1.4 Resource files and HTML access......Page 97
5.2 The deployment descriptor: an overview......Page 98
5.2.1 Example: A simple deployment descriptor......Page 99
5.2.2 Using the element......Page 100
5.2.3 Using the element......Page 102
5.2.4 Mapping a URL to a servlet......Page 103
5.4 Review questions......Page 107
The servlet container model......Page 110
6.1 Initializing ServletContext......Page 111
6.2.1 Adding and removing scope attributes......Page 112
6.2.2 Listening to attribute events......Page 113
6.3.1 javax.servlet.ServletContextListener......Page 115
6.3.3 javax.servlet.Http.HttpServletRequestListener......Page 116
6.4 Adding listeners in the deployment descriptor......Page 117
6.5.1 Behavior of a ServletContext......Page 119
6.5.2 Behavior of an HttpSession......Page 120
6.7 Review questions......Page 121
Using filters......Page 124
7.1 What is a filter?......Page 125
7.1.2 Uses of filters......Page 126
7.1.3 The Hello World filter......Page 127
7.2 The Filter API......Page 129
7.2.1 The Filter interface......Page 130
7.2.3 The FilterChain interface......Page 132
7.3.1 The element......Page 133
7.3.3 Configuring a filter chain......Page 134
7.4.1 Using the request and response wrappers......Page 137
7.4.3 Using filters with MVC......Page 143
7.6 Review questions......Page 144
Session management......Page 146
8.1 Understanding state and sessions......Page 147
8.2 Using HttpSession......Page 148
8.2.1 Working with an HttpSession......Page 149
8.2.2 Handling session events with listener interfaces......Page 151
8.3 Understanding session timeout......Page 157
8.4 Implementing session support......Page 158
8.4.1 Supporting sessions using cookies......Page 159
8.4.2 Supporting sessions using URL rewriting......Page 160
8.6 Review questions......Page 163
Developing secure web applications......Page 166
9.1.2 Authorization......Page 167
9.1.7 Web site attacks......Page 168
9.2 Understanding authentication mechanisms......Page 169
9.2.1 HTTP Basic authentication......Page 170
9.2.3 HTTPS Client authentication......Page 172
9.2.5 Defining authentication mechanisms for web applications......Page 173
9.3.2 web-resource-collection......Page 176
9.3.3 auth-constraint......Page 177
9.3.4 user-data-constraint......Page 178
9.3.5 Putting it all together......Page 179
9.4 Securing web applications programmatically......Page 183
9.5 Summary......Page 185
9.6 Review questions......Page 186
Part 3 - JavaServer Pages and Design Patterns......Page 190
The JSP technology model-the basics......Page 192
10.1 SP syntax elements......Page 193
10.1.1 Directives......Page 194
10.1.2 Declarations......Page 195
10.1.3 Scriptlets......Page 196
10.1.4 Expressions......Page 197
10.1.5 Actions......Page 198
10.1.6 Comments......Page 199
10.2 The JSP page life cycle......Page 200
10.2.2 Understanding translation units......Page 201
10.2.3 JSP life-cycle phases......Page 202
10.2.4 JSP life-cycle example......Page 205
10.3 Understanding JSP page directive attributes......Page 208
10.3.3 The errorPage and isErrorPage attributes......Page 209
10.3.5 The buffer and autoFlush attributes......Page 211
10.3.7 The contentType and pageEncoding attributes......Page 212
10.5 Review questions......Page 213
The JSP technology model-advanced topics......Page 215
11.1.1 Using scripting elements......Page 216
11.1.2 Using conditional and iterative statements......Page 218
11.1.4 Using escape sequences......Page 221
11.2 Understanding JSP implicit variables and JSP implicit objects......Page 225
11.2.1 application......Page 227
11.2.2 session......Page 228
11.2.5 pageContext......Page 229
11.2.6 out......Page 230
11.2.7 config......Page 231
11.2.8 exception......Page 233
11.3.2 Session scope......Page 234
11.3.3 Request scope......Page 235
11.3.4 Page scope......Page 236
11.4 JSP pages as XML documents......Page 238
11.4.1 The root element......Page 239
11.4.2 Directives and scripting elements......Page 240
11.4.3 Text, comments, and actions......Page 241
11.5 Summary......Page 242
11.6 Review questions......Page 243
Reusable web components......Page 246
12.1 Static inclusion......Page 247
12.1.1 Accessing variables from the included page......Page 248
12.1.2 Implications of static inclusion......Page 249
12.2.1 Using jsp:include......Page 250
12.2.2 Using jsp:forward......Page 252
12.2.3 Passing parameters to dynamically included components......Page 253
12.2.4 Sharing objects with dynamically included components......Page 255
12.4 Review questions......Page 259
Creating JSPs with the Expression Language (EL)......Page 263
13.1.1 EL expressions and JSP script expressions......Page 264
13.1.2 Using implicit variables in EL expressions......Page 265
13.2.1 EL operators for property and collection access......Page 268
13.2.2 EL arithmetic operators......Page 269
13.2.3 EL relational and logical operators......Page 270
13.3.1 Creating the static methods......Page 271
13.3.2 Creating a tag library descriptor (TLD)......Page 272
13.3.3 Modifying the deployment descriptor......Page 273
13.3.4 Accessing EL functions within a JSP......Page 274
13.5 Review questions......Page 276
Using JavaBeans......Page 278
14.1.1 JavaBeans from the JSP perspective......Page 279
14.1.2 The JavaBean advantage......Page 280
14.1.3 Serialized JavaBeans......Page 282
14.2.1 Declaring JavaBeans using ......Page 285
14.2.2 Mutating properties using ......Page 293
14.2.3 Accessing properties using ......Page 296
14.3 JavaBeans in servlets......Page 298
14.4 Accessing JavaBeans from scripting elements......Page 301
14.5.1 Using nonstring data type properties......Page 303
14.5.2 Using indexed properties......Page 305
14.6 Summary......Page 307
14.7 Review questions......Page 308
Using custom tags......Page 312
15.1.1 New terms......Page 313
15.1.2 Understanding tag libraries......Page 314
15.2 Informing the JSP engine about a custom tag library......Page 315
15.2.1 Location of a TLD file......Page 316
15.2.3 Understanding explicit mapping......Page 317
15.2.4 Resolving URIs to TLD file locations......Page 318
15.3 Using custom tags in JSP pages......Page 320
15.3.1 Empty tags......Page 321
15.3.2 Tags with attributes......Page 322
15.3.3 Tags with JSP code......Page 323
15.3.4 Tags with nested custom tags......Page 324
15.4.1 Acquiring and installing the JSTL......Page 325
15.4.2 General purpose JSTL tags: and ......Page 326
15.4.3 Variable support JSTL tags: and ......Page 327
15.4.4 Flow control JSTL: , , , and ......Page 328
15.6 Review questions......Page 332
Developing “classic” custom tag libraries......Page 336
16.1 Understanding the tag library descriptor......Page 337
16.1.1 The element......Page 338
16.1.2 The element......Page 340
16.1.3 The element......Page 341
16.1.4 The element......Page 343
16.2 The Tag Extension API......Page 345
16.3 Implementing the Tag interface......Page 347
16.3.1 Understanding the methods of the Tag interface......Page 348
16.3.2 An empty tag that prints HTML text......Page 351
16.3.3 An empty tag that accepts an attribute......Page 353
16.3.4 A nonempty tag that includes its body content......Page 355
16.4.1 Understanding the IterationTag methods......Page 356
16.4.2 A simple iterative tag......Page 357
16.5 Implementing the BodyTag interface......Page 360
16.5.1 Understanding the methods of BodyTag......Page 361
16.5.2 A tag that processes its body......Page 362
16.6.1 The TagSupport class......Page 365
16.6.3 Accessing implicit objects......Page 366
16.6.4 Writing cooperative tags......Page 370
16.7 What’s more?......Page 374
16.8 Summary......Page 375
16.9 Review questions......Page 376
Developing “Simple” custom tag libraries......Page 379
17.1.1 A brief example......Page 380
17.1.2 Exploring SimpleTag and SimpleTagSupport......Page 381
17.2.1 Coding empty SimpleTags......Page 384
17.2.2 Adding dynamic attributes to SimpleTags......Page 386
17.2.3 Processing body content inside SimpleTags......Page 389
17.3.1 Introducing tag files......Page 391
17.3.2 Tag files and TLDs......Page 392
17.3.3 Controlling tag processing with tag file directives......Page 393
17.3.4 Processing fragments and body content with tag file actions......Page 395
17.4 Summary......Page 398
17.5 Review questions......Page 399
Design patterns......Page 403
18.1.2 The Gang of Four patterns......Page 404
18.1.4 The J2EE patterns......Page 406
18.2.1 The pattern template......Page 409
18.2.2 The Intercepting Filter......Page 412
18.2.3 Model-View-Controller (MVC)......Page 413
18.2.4 Front Controller......Page 416
18.2.5 Service Locator......Page 418
18.2.6 Business Delegate......Page 420
18.2.7 Transfer Object......Page 424
18.3 Summary......Page 427
18.4 Review questions......Page 428
A.3 Installation......Page 430
A.4 Directory Structure......Page 431
A.5 Running Tomcat......Page 432
A.7 Security......Page 433
A sample web.xml file......Page 435
Review Q & A......Page 439
Exam Quick Prep......Page 502
B......Page 550
D......Page 551
G......Page 552
I......Page 553
L......Page 554
R......Page 555
S......Page 556
U......Page 557
Z......Page 558

SCWCD Exam Study Kit: Java Web Component Developer Certification [2nd ed.]
 1932394389, 9781932394382

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers