|
Sun Certified Web Component Developer Study Companion (SCWCD 5)
This book is a study guide for any candidate preparing for the new Java EE 5 version of the Sun Certified Web Component Developer exam (310-083) and upgrade (310-084). It contains the theory behind why the Web container operates as it does, and important notes, hints and tips on the types of 'trick' questions to look for in the exam. By combining logical
and easy-to-follow discussions with clear visual aids and diagrams, you will learn how the container works, and, by the end of the book, you'll be wondering why servlets, JSPs and tag libraries seemed so complicated before. By combining the theory taught in this book with practical experience, you will not only succeed in passing the exam, but will do so confident that you are able to solve problems and draw-up solutions 'on the job'.
CONTENTS:
Part I: The J2EE Environment
Chapter 1: Networks and HTTP
Networked Environments
The Internet
IP Addresses
Domain Name System (DNS)
URIs, URLs and URNs
The Client-Server Model
The Transfer of Data and Network Protocols
Protocols in General
Standard Protocols
The Hypertext Transfer Protocol (HTTP)
Requests and Responses
Headers and Bodies
HTTP Versions
HTTP Methods
The GET Method
The POST Method
The HEAD Method
The OPTIONS Method
The PUT Method
The DELETE Method
The TRACE Method
The CONNECT Method
Cookies
Security
Common Uses
Revision Questions
Answers to Revision Questions
Chapter 2: J2EE Architecture
What is the J2EE Platform?
Web Components
Web Applications
Web Containers
Web Application Contexts
Communication between Applications
Packaging Applications: the WAR File
WAR Files
Context Paths
WAR Structure
The WEB-INF Directory
The Deployment Descriptor
Key J2EE Web Components
Revision Questions
Answers to Revision Questions
Part II: Servlets
Chapter 3: Servlet Basics
What are Servlets?
The Interfaces
Servlet Life Cycles
Servlet Class Loading
Servlet Instantiation
Initialisation
Initialisation Exceptions
Request Servicing
HttpServlet Request Servicing
Service Exceptions
The destroy Method
HttpServlet doXxx Methods
Subclassing the doXxx() Methods
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 4: Servlet Contexts
Servlets in Context
The ServletContext Interface
Context (Application-Scoped) Attributes
Obtaining Context Information
Accessing Static Resources
Obtaining RequestDispatchers
Context Initialisation Parameters
The ServletConfig Interface
Servlet Names and Contexts
Servlet Initialisation Parameters
GenericServlets
Initialisation
Convenience Methods
The ServletContext Life Cycle
Context Listeners
The ServletContextListener Interface
The ServletContextEvent Class
The ServletContextAttributeListener Interface
The ServletContextAttributeEvent Class
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 5: Requests and Responses
The ServletRequest Interface
Request-Scoped Attributes
Request Protocol and Transmission Data (Not an Exam Objective)
Request Parameters
Requested Resource Information (Not an Exam Objective)
Client Information (Not an Exam Objective)
Reading Request Bodies
Request Dispatching
The HttpServletRequest Interface
Request Headers
Request Protocol Data and Resource Path (Not an Exam Objective)
Security-Related Methods
Cookies
Session Management
The ServletResponse Interface
Response Streams
Response Protocol and Transmission Data
The HttpServletResponse Interface
Response Headers
HTTP Status Codes and Redirection
URL Rewriting
Cookies
Request Listeners
The ServletRequestListener Interface
The ServletRequestEvent Class
The ServletRequestAttributeListener Interface
The ServletRequestAttributeEvent Class
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 6: Request Dispatching and Wrappers
The RequestDispatcher Mechanism
The RequestDispatcher Interface
Using RequestDispatchers
Foreign Context RequestDispatchers
Additional Request Attributes
Wrapping Requests and Responses
The ServletRequestWrapper Class
The HttpServletRequestWrapper Class
The ServletResponseWrapper Class
The HttpServletResponseWrapper Class
Wrappers and the Exam
Wrappers and RequestDispatchers
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 7: Filters
The Filter Mechanism
Why use Filters?
Filter Chains
Suitable Filter Ordering
The Filter Life Cycle
The Filter API
The Filter Interface
Initialisation Exceptions
Filter Servicing
The FilterChain Interface
The FilterConfig Interface
Filter vs. RequestDispatcher Mechanisms
RequestDispatcher Interception
Filters and Wrappers
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 8: Session Management
Session Tracking
Cookies
URL Rewriting
SSL Sessions
Session Life Cycles
Passivation
Sessions in Distributed Applications
The Session API
Session-Scoped Attributes
Life Cycle
Session Listeners
The HttpSessionListener Interface
The HttpActivationListener Interface
The HttpSessionEvent Class
The HttpSessionAttributeListener Interface
The HttpSessionBindingListener Interface
The HttpSessionBindingEvent Class
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 9: Application Deployment
The Deployment Descriptor
Basic Syntax
The Element
Web Application Metadata
Context Parameters
Filter Configuration
Filter Mappings
Listener Configuration
Servlet Configuration
Servlet Mappings
Session Configuration
MIME Mappings
Welcome Files
Error Pages
JSP Configuration
Security Configuration
Application Deployment
Revision Questions
Exhibits
Answers to Revision Questions
Part III: JavaServer Pages
Chapter 10: JSP Basics
Codeless JSP Pages
The JSP Life Cycle
Scripting Elements
Directives
The page Directive
The taglib Directive
The include Directive
Declarations
Scriptlets
Expressions
Comments
Implicit Objects
The PageContext API
The JspContext Abstract Class
The PageContext Abstract Class
Practical Uses of the PageContext API
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 11: JSP Documents
The XML View
Document Structure
XML Namespaces
The Root Element
Template Text
Directives and Scripting Elements
Advanced Template Text and CDATA Sections
Revision Questions
Answers to Revision Questions
Chapter 12: Expression Language
Enter The Expression Language
Basic Syntax
Expression Demarcation
Expressions and Template Text
Escaping
Expression Language Data Types
Putting EL to Use
Expressions as Template Attribute Values
Expressions in Actions
Variable Resolution
The ExpressionEvaluator Class and VariableResolver Interface
Implicit Objects
Operators
Property and Collection Access
Compounding Property and Collection Operators
[] and Operator Exceptions
Standard Operators
The Empty Operator
Operator Precedence
Functions
Using EL Functions
Writing Custom EL Functions
Errors and Exceptions
Configuring EL and Scripting in JSPs
Evaluation of Scripting Elements
Evaluation of EL Expressions in JSPs
What You Need to Know - Exam-wise!
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 13: Standard Actions and JavaBeans
What are Actions Anyway?
Benefits of Actions
Action Syntax
JavaBeans: Ground Coffee?
Constructors
Properties and the Default Introspector
Other Methods
Standard Actions for the Exam
Further Standard Actions (Not an Exam Objective)
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 14: Tag Libraries and the JSTL
Tag Libraries in JSPs
Deploying a Tag Library
The taglib Directive
The JavaServer Pages Standard Tag Library (JSTL)
Dynamic vs. Static Attributes
JSTL Versions and Libraries
Which Library do I Use?
Java Standard Tag Library URIs
The JSTL Core Library
Output Parser:
Exception Handling:
Scoped Attribute Modification: and
Conditional Evaluation:
Conditional Choice: , ,
Looping:
Token Iteration:
URL Formatting:
Importing Resources:
Redirection:
Request Parameters:
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 15: Custom Tags
JSP's Custom Tags
Classic Tags vs. Tag Files
Tag Life Cycles
Classic Tag Extensions
The Tag Interface
The IterationTag Interface
The TagSupport Class
The BodyTag Interface
The BodyTagSupport Class
Simple Tag Handlers
The SimpleTagSupport Class
JSP Fragments
The JspFragment Class
Simple Tag Handlers: Useful or Useless?
SimpleTag vs. Tag Life Cycles
Advanced Tag Functionality
Actions with Attributes
Dynamic Attributes
Attribute Fragments
Introducing Scripting Variables into a JSP
Configuration of Scripting Variables for a Tag
Nested Tags and Cooperating Actions
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 16: Tag Files
Basic Tag File Syntax
Tag File Semantics
Directives
The tag Directive
The attribute Directive
The variable Directive
Implicit Objects
Invoking Body Fragments: Standard Actions
Variable Synchronisation
Employing Other Actions
An Example
calendar.tag
calendarx.tagx
calendartest.jsp
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 17: Tag Deployment
Tag Libraries
Assembly and Deployment
Tags and Tag Files in Tag Libraries
Tags in Applications
Tag Files in Applications
The Implicit TLD for Tag Files
Using Tags in JSPs
The taglib Directive
Identifying and Locating Explicit TLDs with URIs
Which URI Mechanism Should I Use?
Tag Library Descriptor (TLD) Syntax
General TLD Template
Root Element
Revision Questions
Answers to Revision Questions
Part IV: Further Topics
Chapter 18: Security
Methods for Authentication
Basic Authentication
Digest Authentication
Form Authentication
SSL Certificates
Authentication and Sessions
Declarative Authentication
Basic, Digest and Client-Cert Authentication
Form Authentication
Performing Authorisation
Declaring Security Roles
Security Roles in Applications
Assigning Users to Roles
Web Security and EJBs
Declarative Authorisation and Confidentiality
Defining Resource Collections
Authorisation Constraints
Confidentiality and Data Integrity
Servlets and Role References
Deployment Descriptor Syntax Summary
Getting Started with Programmatic Security (Not on the Exam)
Programmatic Authorisation with Servlets
Revision Questions
Exhibits
Answers to Revision Questions
Chapter 19: J2EE Patterns
General Patterns and Tiered Architectures
Model-View-Controller (MVC) Pattern
Application Tiers
Patterns for the Presentation Tier
Front Controller
Intercepting Filter
Patterns for the Business Logic Tier
Business Delegate
Service Locator
Transfer Object
Patterns for the Presentation Tier (Not an Exam Objective)
View Helper
Composite View
Dispatcher View (Composite)
Service to Worker (Composite)
Revision Questions
Answers to Revision Questions
Part V: Java EE 5
Chapter 20: Servlet 2.5 and JSP 2.1 Changes
JavaServer Faces 1.2
Servlet 2.5 Changes
Deployment Descriptor
Requests and Responses
Annotations and Resource Injection
@DeclareRoles (JSR-250)
@RunAs (JSR-250)
@Resource and @Resources (JSR-250)
@PostConstruct and @PreDestroy (JSR-250)
@EJB (JSR-220)
@WebServiceRef (JSR-224)
Performance Issues
JSP 2.1 Basic Changes
Whitespace Trimming
Comments in JSP Documents
Clarification on Tag File Naming
Custom Tags
Tag IDs
Supporting Deferred Expressions
Tag Files and Deferred Expressions
Tag File Semantics
Chapter 21: Unified Expression Language (EL 2.1)
Support for Enums
Deferred Expressions
New javax.el API
ELContext
Expression
ValueExpression
MethodExpression
ExpressionFactory
ELResolver
FunctionMapper
VariableMapper
Variable and Property Resolution
Escaping and Disabling EL
Part A: Appendices
Appendix A: Exam Objectives
Appendix B: Mock Exam Subscription
Index
|