| Intro |
|
xix | |
| Your brain on Servlets |
|
| Who is this book for? |
|
xx | |
| We know what your brain is thinking |
|
xxi | |
| Metacognition |
|
xxiii | |
| Bend your brain into submission |
|
xxv | |
| What you need for this book |
|
xxvi | |
| Passing the certification exam |
|
xxviii | |
| Technical reviewers |
|
xxx | |
| Acknowledgements |
|
xxxi | |
|
|
|
1 | (36) |
|
|
|
|
|
|
2 | (2) |
|
What web servers and clients do, and how they talk |
|
|
4 | (3) |
|
|
|
7 | (3) |
|
What is the HTTP protocol? |
|
|
10 | (5) |
|
Anatomy of HTTP Get and Post requests and HTTP responses |
|
|
15 | (5) |
|
Locating web pages using URLs |
|
|
20 | (4) |
|
Web servers, static web pages, and CGI |
|
|
24 | (6) |
|
Servlets Demystified: write, deploy, and run a servlet |
|
|
30 | (4) |
|
JSP is what happened when somebody introduced Java to HTML |
|
|
34 | (3) |
|
|
|
37 | (30) |
|
|
|
|
|
|
38 | (1) |
|
What is a Container and what does it give you? |
|
|
39 | (5) |
|
How it looks in code (what makes a servlet a servlet) |
|
|
44 | (2) |
|
Naming servlets and mapping them to URLs using the DD |
|
|
46 | (4) |
|
Story: Bob Builds a Matchmaking Site (an MVC intro) |
|
|
50 | (4) |
|
A Model-View-Controller (MVC) overview and example |
|
|
54 | (10) |
|
A ``working'' Deployment Descriptor (DD) |
|
|
64 | (1) |
|
How J2EE fits into all this |
|
|
65 | (2) |
|
|
|
67 | (26) |
|
Create and deploy an MVC web app |
|
|
|
|
|
68 | (1) |
|
Let's build an MVC application; first the design |
|
|
69 | (3) |
|
Create the development and deployment environments |
|
|
72 | (3) |
|
Create and test the HTML for the initial form page |
|
|
75 | (2) |
|
Create the Deployment Descriptor (DD) |
|
|
77 | (3) |
|
Create, compile, depoly, and test the controller servlet |
|
|
80 | (2) |
|
Design, build, and test the model component |
|
|
82 | (1) |
|
Enhance the controller to call the model |
|
|
83 | (4) |
|
Create and deploy the view component; (it's a JSP) |
|
|
87 | (1) |
|
Enhance the controller servlet to call the JSP |
|
|
88 | (5) |
|
|
|
93 | (54) |
|
Servlets live to service clients |
|
|
|
|
|
94 | (1) |
|
A servlet's life in the Container |
|
|
95 | (6) |
|
Servlet initialization and threads |
|
|
101 | (4) |
|
A servlet's Real job is to handle Get and Post requests |
|
|
105 | (7) |
|
The story of the non-idempotent request |
|
|
112 | (5) |
|
What determines whether you get a Get or Post request? |
|
|
117 | (2) |
|
Sending and using parameter(s) |
|
|
119 | (7) |
|
So that's the Request... now let's see the Response |
|
|
126 | (7) |
|
You can set response headers, you can add response headers |
|
|
133 | (3) |
|
Servlet redirect vs. request dispatcher |
|
|
136 | (4) |
|
Review: HttpServletResponse |
|
|
140 | (7) |
|
|
|
147 | (74) |
|
|
|
|
|
|
148 | (1) |
|
Init Parameters and ServletConfig to the rescue |
|
|
149 | (6) |
|
How can a JSP get servlet init parameters? |
|
|
155 | (2) |
|
Context init parameters to the rescue |
|
|
157 | (2) |
|
Comparing ServletConfig and ServletContext |
|
|
159 | (5) |
|
She wants a ServletContextListener |
|
|
164 | (4) |
|
Tutorial: write a simple ServletContextListener |
|
|
168 | (8) |
|
Compile, deploy, and test your listener |
|
|
176 | (2) |
|
The full story, a ServletContext Listener review |
|
|
178 | (2) |
|
Eight Listeners: they're not just for context events... |
|
|
180 | (5) |
|
What, exactly, is an attribute, and what are its scopes? |
|
|
185 | (4) |
|
The Attribute API and the dark side of attributes... |
|
|
189 | (2) |
|
Context scope isn't thread-safe! |
|
|
191 | (3) |
|
How do we make context attributes thread-safe? |
|
|
194 | (1) |
|
Trying out Synchronization |
|
|
195 | (3) |
|
Are Session attributes thread-safe? |
|
|
198 | (3) |
|
The evils of Single ThreadModel |
|
|
201 | (1) |
|
Only Request attributes and local variables are thread-safe! |
|
|
202 | (1) |
|
Request attributes and Request dispatching |
|
|
203 | (18) |
|
|
|
221 | (58) |
|
Web servers have no short-term memory |
|
|
|
|
|
222 | (2) |
|
It's supposed to be a conversation, (how sessions work) |
|
|
224 | (5) |
|
Session IDs, cookies, and other session basics |
|
|
229 | (5) |
|
URL rewriting: something to fall back on |
|
|
234 | (5) |
|
When sessions get stale; getting rid of bad sessions |
|
|
239 | (9) |
|
Can I use cookies for other things besides sessions? |
|
|
248 | (4) |
|
Key milestones for an HttpSession |
|
|
252 | (2) |
|
Don't forget about HttpSessionBindingListener |
|
|
254 | (1) |
|
|
|
255 | (4) |
|
|
|
259 | (20) |
|
|
|
279 | (62) |
|
|
|
|
|
|
280 | (1) |
|
Create a simple JSP using ``out'' and a page directive |
|
|
281 | (5) |
|
JSP expressions, variables, and declarations |
|
|
286 | (8) |
|
Time to see a JSP-generated servlet |
|
|
294 | (2) |
|
The out variable isn't the only implicit object... |
|
|
296 | (8) |
|
The Lifecycle and initialization of a JSP |
|
|
304 | (8) |
|
While we're on the subject... the three directives |
|
|
312 | (3) |
|
Scriptlets considered harmful? Here's EL |
|
|
315 | (6) |
|
But wait... we haven't seen: actions |
|
|
321 | (20) |
|
|
|
341 | (92) |
|
|
|
|
|
|
342 | (1) |
|
When attributes are beans |
|
|
343 | (3) |
|
Standard actions: useBean, getProperty, setProperty |
|
|
346 | (6) |
|
Can you make polymorphic bean references? |
|
|
352 | (6) |
|
The param attribute to the rescue |
|
|
358 | (3) |
|
|
|
361 | (5) |
|
Expression Language (EL) saves the day! |
|
|
366 | (2) |
|
Using the dot (.) operator to access properties and map values |
|
|
368 | (1) |
|
The [ ] gives you more options (Lists, arrays...) |
|
|
369 | (5) |
|
More dot and [ ] operator details |
|
|
374 | (7) |
|
|
|
381 | (6) |
|
EL functions, and handling ``null'' |
|
|
387 | (11) |
|
Reusable template pieces---two kinds of ``include'' |
|
|
398 | (11) |
|
The <jsp:forward> standard action |
|
|
409 | (4) |
|
She doesn't know about JSTL tags (a preview) |
|
|
413 | (1) |
|
Reviewing standard actions and include |
|
|
414 | (19) |
|
|
|
433 | (56) |
|
Sometimes you need more than EL or standard actions |
|
|
|
|
|
434 | (2) |
|
Looping without scripting; <c:forEach> |
|
|
436 | (5) |
|
Conditional control with <c:if> and <c:choose> |
|
|
441 | (4) |
|
Using the <c:set> and <c:remove> tags |
|
|
445 | (5) |
|
With <c:import>, there are three ways to include content |
|
|
450 | (2) |
|
Customizing the thing you include |
|
|
452 | (1) |
|
Doing the same thing with <c:param> |
|
|
453 | (2) |
|
<c:url> for all your hyperlink needs |
|
|
455 | (3) |
|
Make your own error pages |
|
|
458 | (4) |
|
The <c:catch> tag. Like try/catch...sort of |
|
|
462 | (3) |
|
What if you need a tag that's Not in JSTL? |
|
|
465 | (5) |
|
Pay attention to <rtexprvalue> |
|
|
470 | (2) |
|
What can be in a tag body |
|
|
472 | (1) |
|
The tag handler, the TLD, and the JSP |
|
|
473 | (1) |
|
The taglib <uri> is just a name, not a location |
|
|
474 | (3) |
|
When a JSP uses more than one tag library |
|
|
477 | (12) |
|
When even JSTL isn't enough... |
|
|
489 | (80) |
|
Sometimes JSTL and standard actions aren't enough |
|
|
|
|
|
490 | (2) |
|
Tag Files: like include, only better |
|
|
492 | (7) |
|
Where the Container looks for Tag Files |
|
|
499 | (3) |
|
|
|
502 | (7) |
|
What if the tag body uses an expression? |
|
|
509 | (10) |
|
You still have to know about Classic tag handlers |
|
|
519 | (1) |
|
|
|
520 | (1) |
|
A very small Classic tag handler |
|
|
521 | (5) |
|
The Classic lifecycle depends on return values |
|
|
526 | (1) |
|
Iteration Tag lets you repeat the body |
|
|
527 | (2) |
|
Default return values from TagSupport |
|
|
529 | (4) |
|
With BodyTag, you get two new methods |
|
|
533 | (4) |
|
What if you have tags that work together? |
|
|
537 | (10) |
|
Using the PageContext API for tag handlers |
|
|
547 | (22) |
|
|
|
569 | (48) |
|
Finally, your web app is ready for prime time |
|
|
|
|
|
570 | (1) |
|
Key deployment task, what goes where? |
|
|
571 | (8) |
|
|
|
579 | (5) |
|
How servlet mapping Really works |
|
|
584 | (6) |
|
Configuring welcome files in the DD |
|
|
590 | (4) |
|
Configuring error pages in the DD |
|
|
594 | (2) |
|
Configuring servlet initialization in the DD |
|
|
596 | (1) |
|
Making an XML-compliant JSP: a JSP Document |
|
|
597 | (20) |
|
Keep it secret, keep it safe |
|
|
617 | (52) |
|
Your web app is in danger |
|
|
|
|
|
618 | (3) |
|
The Big 4 in servlet security |
|
|
621 | (3) |
|
How to Authenticate in HTTP World |
|
|
624 | (3) |
|
Top Ten Reasons to do your security declaratively |
|
|
627 | (1) |
|
Who implements security in a web app? |
|
|
628 | (3) |
|
Authorization: roles and constraints |
|
|
631 | (14) |
|
Authentication: four flavors |
|
|
645 | (1) |
|
The Four authentication types |
|
|
645 | (4) |
|
Securing data in transit: HTTPS to the rescue |
|
|
649 | (3) |
|
Data confidentiality and integrity sparingly and declaratively |
|
|
652 | (17) |
|
|
|
669 | (36) |
|
Filters let you intercept the request |
|
|
|
|
|
670 | (5) |
|
Building a request tracking filter |
|
|
675 | (1) |
|
|
|
676 | (2) |
|
Declaring and ordering filters |
|
|
678 | (3) |
|
Compressing output with a response-side filter |
|
|
681 | (6) |
|
|
|
687 | (3) |
|
The real compression filter code |
|
|
690 | (2) |
|
|
|
692 | (13) |
|
Enterprise design patterns |
|
|
705 | (132) |
|
Someone has done this already |
|
|
|
|
|
706 | (1) |
|
Hardware and software forces behind patterns |
|
|
707 | (4) |
|
Review of software design principles... |
|
|
711 | (2) |
|
Patterns to support remote model components |
|
|
713 | (2) |
|
|
|
715 | (5) |
|
The Business Delegate is a ``go-between'' |
|
|
720 | (2) |
|
Simplify your Business Delegates with the Service Locator |
|
|
722 | (4) |
|
Time for a Transfer Object? |
|
|
726 | (4) |
|
Our very first pattern revisited... MVC |
|
|
730 | (5) |
|
Yes! It's Struts (and Front Controller), in a nutshell |
|
|
735 | (3) |
|
Refactoring the Beer app for Struts |
|
|
738 | (8) |
|
|
|
746 | (13) |
|
|
|
|
The final Coffee Cram Mock Exam |
|
|
|
|
|
759 | (39) |
|
|
|
798 | (39) |
| Index |
|
837 | |