SCWCD Exam Study Kit Second Edition
Java Web Component Developer Certification
Hanumant Deshmukh, Jignesh Malavia, and Matthew Scarpino
  • May 2005
  • ISBN 9781932394382
  • 560 pages

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 detailed table of contents

preface to the second edition

preface to the first edition

acknowledgments

about the Sun certification exams

about this book

about the authors

about the cover illustration

Part 1 Getting started

1. Understanding Java servlets

1.1. What is a servlet?

1.1.1. Server responsibilities

1.1.2. Server extensions

1.2. What is a servlet container?

1.2.1. The big picture

1.2.2. Understanding servlet containers

1.2.3. Using Tomcat

1.3. Hello World servlet

1.3.1. The code

1.3.2. Compilation

1.3.3. Deployment

1.3.4. Execution

1.4. The relationship between a servlet container and the Servlet API

1.4.1. The javax.servlet package

1.4.2. The javax.servlet.http package

1.4.3. Advantages and disadvantages of the Servlet API

1.5. Summary

2. Understanding JavaServer Pages

2.1. What is a JSP page?

2.1.1. Server-side includes

2.2. Hello User

2.2.1. The HTML code

2.2.2. The servlet code

2.2.3. The JSP code

2.3. Servlet or JSP?

2.4. JSP architecture models

2.4.1. The Model 1 architecture

2.4.2. The Model 2 architecture

2.5. A note about JSP syntax

2.6. Summary

3. Web application and HTTP basics

3.1. What is a web application?

3.1.1. Active and passive resources

3.1.2. Web applications and the web application server

3.2. Understanding the HTTP protocol

3.2.1. HTTP basics

3.2.2. The structure of an HTTP request

3.2.3. The structure of an HTTP response

3.3. Summary

Part 2 Servlets

4. The servlet model

4.1. Sending requests: Web browsers and HTTP methods

4.1.1. Comparing HTTP methods

4.2. Handling HTTP requests in an HttpServlet

4.3. Analyzing the request

4.3.1. Understanding ServletRequest

4.3.2. Understanding HttpServletRequest

4.4. Sending the response

4.4.1. Understanding ServletResponse

4.4.2. Understanding HttpServletResponse

4.5. Servlet life cycle

4.5.1. Loading and instantiating a servlet

4.5.2. Initializing a servlet

4.5.3. Servicing client requests

4.5.4. Destroying a servlet

4.5.5. Unloading a servlet

4.5.6. Servlet state transition from the servlet container’s perspective

4.6. ServletConfig: a closer look

4.6.1. ServletConfig methods

4.6.2. Example: a servlet and its deployment descriptor

4.7. ServletContext: a closer look

4.8. Beyond servlet basics

4.8.1. Sharing the data (attribute scopes)

4.8.2. Coordinating servlets using RequestDispatcher

4.8.3. Accessing request-scoped attributes with RequestDispatcher

4.8.4. Putting it all together: A simple banking application

4.9. Summary

4.10. Review questions

5. Structure and deployment

5.1. Directory structure of a web application

5.1.1. Understanding the document root directory

5.1.2. Understanding the WEB-INF directory

5.1.3. The web archive (WAR) file

5.1.4. Resource files and HTML access

5.1.5. The default web application

5.2. The deployment descriptor: an overview

5.2.1. Example: A simple deployment descriptor

5.2.2. Using the <servlet> element

5.2.3. Using the <servlet-mapping> element

5.2.4. Mapping a URL to a servlet

5.3. Summary

5.4. Review questions

6. The servlet container model

6.1. Initializing ServletContext

6.2. Adding and listening to scope attributes

6.2.1. Adding and removing scope attributes

6.2.2. Listening to attribute events

6.3. Servlet life-cycle events and listeners

6.3.1. javax.servlet.ServletContextListener

6.3.2. javax.servlet.Http.HttpSessionListener

6.3.3. javax.servlet.Http.HttpServletRequestListener

6.4. Adding listeners in the deployment descriptor

6.5. Web applications in a distributed environment

6.5.1. Behavior of a ServletContext

6.5.2. Behavior of an HttpSession

6.6. Summary

6.7. Review questions

7. Using filters

7.1. What is a filter?

7.1.1. How filtering works

7.1.2. Uses of filters

7.1.3. The Hello World filter

7.2. The Filter API

7.2.1. The Filter interface

7.2.2. The FilterConfig interface

7.2.3. The FilterChain interface

7.2.4. The request and response wrapper classes

7.3. Configuring a filter

7.3.1. The <filter> element

7.3.2. The <filter-mapping> element

7.3.3. Configuring a filter chain

7.4. Advanced features

7.4.1. Using the request and response wrappers

7.4.2. Important points to remember about filters

7.4.3. Using filters with MVC

7.5. Summary

7.6. Review questions

8. Session management

8.1. Understanding state and sessions

8.2. Using HttpSession

8.2.1. Working with an HttpSession

8.2.2. Handling session events with listener interfaces

8.2.3. Invalidating a Session

8.3. Understanding session timeout

8.4. Implementing session support

8.4.1. Supporting sessions using cookies

8.4.2. Supporting sessions using URL rewriting

8.5. Summary

8.6. Review questions

9. Developing secure web applications

9.1. Basic concepts

9.1.1. Authentication

9.1.2. Authorization

9.1.3. Data integrity

9.1.4. Confidentiality or data privacy

9.1.5. Auditing

9.1.6. Malicious code

9.1.7. Web site attacks

9.2. Understanding authentication mechanisms

9.2.1. HTTP Basic authentication

9.2.2. HTTP Digest authentication

9.2.3. HTTPS Client authentication

9.2.4. FORM-based authentication

9.2.5. Defining authentication mechanisms for web applications

9.3. Securing web applications declaratively

9.3.1. display-name

9.3.2. web-resource-collection

9.3.3. auth-constraint

9.3.4. user-data-constraint

9.3.5. Putting it all together

9.4. Securing web applications programmatically

9.5. Summary

9.6. Review questions

Part 3 JavaServer Pages and Design Patterns

10. The JSP technology model—the basics

10.1. SP syntax elements

10.1.1. Directives

10.1.2. Declarations

10.1.3. Scriptlets

10.1.4. Expressions

10.1.5. Actions

10.1.6. Comments

10.2. The JSP page life cycle

10.2.1. JSP pages are servlets

10.2.2. Understanding translation units

10.2.3. JSP life-cycle phases

10.2.4. JSP life-cycle example

10.3. Understanding JSP page directive attributes

10.3.1. The import attribute

10.3.2. The session attribute

10.3.3. The errorPage and isErrorPage attributes

10.3.4. The language and extends attributes

10.3.5. The buffer and autoFlush attributes

10.3.6. The info attribute

10.3.7. The contentType and pageEncoding attributes

10.4. Summary

10.5. Review questions

11. The JSP technology model—advanced topics

11.1. Understanding the translation process

11.1.1. Using scripting elements

11.1.2. Using conditional and iterative statements

11.1.3. Using request-time attribute expressions

11.1.4. Using escape sequences

11.2. Understanding JSP implicit variables and JSP implicit objects

11.2.1. application

11.2.2. session

11.2.3. request and response

11.2.4. page

11.2.5. pageContext

11.2.6. out

11.2.7. config

11.2.8. exception

11.3. Understanding JSP page scopes

11.3.1. Application scope

11.3.2. Session scope

11.3.3. Request scope

11.3.4. Page scope

11.4. JSP pages as XML documents

11.4.1. The root element

11.4.2. Directives and scripting elements

11.4.3. Text, comments, and actions

11.5. Summary

11.6. Review questions

12. Reusable web components

12.1. Static inclusion

12.1.1. Accessing variables from the included page

12.1.2. Implications of static inclusion

12.2. Dynamic inclusion

12.2.1. Using jsp:include

12.2.2. Using jsp:forward

12.2.3. Passing parameters to dynamically included components

12.2.4. Sharing objects with dynamically included components

12.3. Summary

12.4. Review questions

13. Creating JSPs with the Expression Language (EL)

13.1. Understanding the Expression Language

13.1.1. EL expressions and JSP script expressions

13.1.2. Using implicit variables in EL expressions

13.2. Using EL operators

13.2.1. EL operators for property and collection access

13.2.2. EL arithmetic operators

13.2.3. EL relational and logical operators

13.3. Incorporating functions with EL

13.3.1. Creating the static methods

13.3.2. Creating a tag library descriptor (TLD)

13.3.3. Modifying the deployment descriptor

13.3.4. Accessing EL functions within a JSP

13.4. Summary

13.5. Review questions

14. Using JavaBeans

14.1. JavaBeans: a brief overview

14.1.1. JavaBeans from the JSP perspective

14.1.2. The JavaBean advantage

14.1.3. Serialized JavaBeans

14.2. Using JavaBeans with JSP actions

14.2.1. Declaring JavaBeans using <jsp:useBean>

14.2.2. Mutating properties using <jsp:setProperty>

14.2.3. Accessing properties using <jsp:getProperty>

14.3. JavaBeans in servlets

14.4. Accessing JavaBeans from scripting elements

14.5. More about properties in JavaBeans

14.5.1. Using nonstring data type properties

14.5.2. Using indexed properties

14.6. Summary

14.7. Review questions

15. Using custom tags

15.1. Getting started

15.1.1. New terms

15.1.2. Understanding tag libraries

15.2. Informing the JSP engine about a custom tag library

15.2.1. Location of a TLD file

15.2.2. Associating URIs with TLD file locations

15.2.3. Understanding explicit mapping

15.2.4. Resolving URIs to TLD file locations

15.2.5. Understanding the prefix

15.3. Using custom tags in JSP pages

15.3.1. Empty tags

15.3.2. Tags with attributes

15.3.3. Tags with JSP code

15.3.4. Tags with nested custom tags

15.4. Using the JSP Standard Tag Library (JSTL)

15.4.1. Acquiring and installing the JSTL

15.4.2. General purpose JSTL tags: <c:catch> and <c:out>

15.4.3. Variable support JSTL tags: <c:set> and <c:remove>

15.4.4. Flow control JSTL: <c:if>, <c:choose>, <c:forEach>, and <c:forTokens>

15.5. Summary

15.6. Review questions

16. Developing "Classic" custom tag libraries

16.1. Understanding the tag library descriptor

16.1.1. The <taglib> element

16.1.2. The <tag> element

16.1.3. The <attribute> element

16.1.4. The <body-content> element

16.2. The Tag Extension API

16.3. Implementing the Tag interface

16.3.1. Understanding the methods of the Tag interface

16.3.2. An empty tag that prints HTML text

16.3.3. An empty tag that accepts an attribute

16.3.4. A nonempty tag that includes its body content

16.4. Implementing the IterationTag interface

16.4.1. Understanding the IterationTag methods

16.4.2. A simple iterative tag

16.5. Implementing the BodyTag interface

16.5.1. Understanding the methods of BodyTag

16.5.2. A tag that processes its body

16.6. Extending TagSupport and BodyTagSupport

16.6.1. The TagSupport class

16.6.2. The BodyTagSupport class

16.6.3. Accessing implicit objects

16.6.4. Writing cooperative tags

16.7. What’s more?

16.8. Summary

16.9. Review questions

17. Developing "Simple" custom tag libraries

17.1. Understanding SimpleTags

17.1.1. A brief example

17.1.2. Exploring SimpleTag and SimpleTagSupport

17.2. Incorporating SimpleTags in JSPs

17.2.1. Coding empty SimpleTags

17.2.2. Adding dynamic attributes to SimpleTags

17.2.3. Processing body content inside SimpleTags

17.3. Creating Java-free libraries with tag files

17.3.1. Introducing tag files

17.3.2. Tag files and TLDs

17.3.3. Controlling tag processing with tag file directives

17.3.4. Processing fragments and body content with tag file actions

17.4. Summary

17.5. Review questions

18. Design patterns

18.1. Design patterns: a brief history

18.1.1. The civil engineering patterns

18.1.2. The Gang of Four patterns

18.1.3. The distributed design patterns

18.1.4. The J2EE patterns

18.2. Patterns for the SCWCD exam

18.2.1. The pattern template

18.2.2. The Intercepting Filter

18.2.3. Model-View-Controller (MVC)

18.2.4. Front Controller

18.2.5. Service Locator

18.2.6. Business Delegate

18.2.7. Transfer Object

18.3. Summary

18.4. Review questions

Appendix A: Installing Tomcat 5.0.25

Appendix B: A sample web.xml file

Appendix C: Review Q & A

Appendix D: Exam Quick Prep

index

What's inside

  • Expression Language
  • JSP Standard Tag Library (JSTL 1.1)
  • Custom tags - "Classic" and "Simple"
  • Session management
  • Security
  • Design patterns
  • Filters
  • Example code and the Tomcat servlet container
  • All exam objectives, carefully explained
  • Review questions and quizlets
  • Quick Prep section for last-minute cramming

About the reader

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.

About the authors

Hanumant Deshmukh, Jignesh Malavia, and Matthew Scarpino, are Sun Certified Web Component Developers who have written a focused and practical book thanks to their extensive background in Java/J2EE design and development. They live, respectively, in Iselin, New Jersey, Ardsley, New York, and Austin, Texas.