nTier’s Introduction to JSP and Servlets training course develops skills in JavaServer Pages, or JSP, which is the standard means of authoring dynamic content for web applications under the Java Enterprise platform. This course presents the important concept of the separation of programmatic and declarative development, i.e., use of configuration and context information in lieu of hard-coded values, resource locations and so on to make the web application as portable and easy to administer as possible.

The course introduces JavaBeans as a standard for business and data objects that can be shared among servlets and JSPs, and develops techniques for sharing such objects at session scope or by request forwarding. Students will learn how to implement filters to adapt existing servlets by pre- and post-processing the request and response. At the end of the course, students will be well prepared to author JSPs for small- or large-scale web applications, either “by hand” (they use only a text editor in class) or using an authoring tool.

Course Duration: 5 days
Prerequisites:

Students should complete an introductory Java class or have at least three months of Java programming experience before taking this course.

Course Objectives:
  • Explain the fundamentals of HTML and HTTP
  • Describe JavaServer Pages and their relationship to servlets and J2EE
  • Describe how a JSP is translated into a servlet and processed at runtime
  • Explain the use of directives on JSPs and outline the principal directives
  • Implement simple JSPs that use Java code in declarations, expressions and scriptlets
  • Enumerate and use the implicit objects available to scripting elements
  • Implement an interactive web application using HTML forms and JSP
  • Use Java exception handling and JSP error pages to handle errors in JSP applications
  • Implement session management for a JSP application
  • Manage cookies to store client-specific information at various scopes and durations
  • Use JavaBeans to implement effective interactive JSP applications
  • Describe custom tags in JSP and explain how they are implemented, both using Java and JSP itself, and how they are used
  • Discuss threading issues in JSP and describe the use of directives to control how threading is handled
  • Describe the various uses of XML in JSP applications
  • Deploy a logical web application to a web server in a WAR file
  • Describe the use of the JSP expression language to simplify dynamic page output
  • Write JSP expressions and implement JSPs that use them in favor of scripts
  • Implement JSPs that use basic JSTL actions to simplify presentation logic
  • Decompose a JSP application design into fine-grained, reusable elements including JavaBeans, custom tag handlers and tag files that use JSTL
  • Use core JSTL actions to complement standard actions, custom actions, and JSP expressions for seamless, script-free page logic
  • Direct conditional and iterative processing of page content by looping through ranges of numbers, over elements in a collection or over tokens in a master string
  • Set locale and time zone information in JSPs and use them to correctly format numbers, dates and times for all clients
  • Use resource bundles to manage application strings and produce the appropriate strings at runtime for a particular client locale
  • Locate a data source, query for relational data and parse result sets
  • Perform updates, inserts and deletes on relational data using SQL actions
  • Manage queries and updates in transaction contexts
  • Derive information from parsed XML content using XPath expressions
  • Implement conditional processing and loops based on XML information
  • Apply XSLT transformations to XML content
  • Implement a simple web service that reads and writes SOAP
  • Understand and appreciate the role of Java Servlets in the overall Java 2 Enterprise Edition architecture and as the best Java solution to HTTP application development
  • Use request and response objects provided to a servlet to read CGI parameters and to produce an HTML response
  • Develop interactive web applications using HTML forms and servlets
  • Manage complex conversations with HTTP clients using session attributes
  • Understand the role of JDBC in Java persistence code and use JDBC for persistence in servlet applications
  • Preserve portability and ease of administration for a servlet application by parameterizing servlet code, using initialization parameters, properties files and JNDI
  • Use JavaBeans classes to share complex business data between components
  • Implement filters to adapt existing servlets with new features and to maximize the decomposition of logic between vertical business functions and horizontal facilities
Course Outline:
  • Web Basics
    • HTML Review – Tags and Document Structure
    • HTTP Overview
      • Requests (GET/POST)
      • Responses
      • URLs
      • Resource Mappings
      • Request Parameters
    • Web Applications
      • Structure
      • WAR File
      • Context Root
      • Deployment
  • Servlet Basics
    • Overview and API
      • Static versus Dynamic Content
      • Servlets
        • Role in a Web App
        • Servlet Interface
        • GenericServlet Class
        • HttpServlet Class
      • Mapping a URL to a Servlet Class
      • Web Container
    • Requests and Responses
      • HttpServletRequest
        • Reading HTTP Request Headers
        • HTML Forms
        • Reading HTTP Request Parameters
      • HttpServletResponse
        • Setting HTTP Response Headers
      • Monitoring Requests and Responses
  • Advanced Servlets
    • Servlet Lifecycle
      • Overview
      • Instantiation
      • Initialization
        • init(ServletConfig) Method
        • init() Method
        • Lazy Initialization
      • Service
        • Service() Method
        • Relationship of service() to doGet()/doPost()
      • Destruction
        • Destroy() <ethod
    • Servlet Configuration
      • ServletConfig Interface
      • Reading Initialization Parameters
    • Deployment Descriptors
      • Web.xml
        • <servlet> Element
        • <servlet-mapping> Element
        • <welcome-file-list> Element
      • Vendor-web.xml
    • Servlet Threading
      • Servlets are Singletons
      • Servlets are Multithreaded
      • Synchronization Techniques
  • Session Tracking
    • HttpSession
      • Need for Sessions
      • HttpSession Class
      • Accessing the Session
      • Session Invalidation
      • Session Timeout
    • Cookies
      • Overview
      • Cookie Class
      • Cookie Expiration
      • Sending Cookies to the Client
      • Retrieving Cookies from the Client
      • JSESSIONID
    • URL Rewriting
      • Overview and Need for URL Rewriting
      • URL Rewriting and HttpSession
    • Scopes
      • Request Scope – ServletRequest Class
      • Session Scope – HttpSession Class
      • Application Scope – ServletContext Class
      • API for Using the Scopes
  • JSP Basics
    • Overview and Motivation
      • Problems with Servlets
      • Motivation for JSPs
      • JSP Runtime Behavior
    • Scripting Elements
      • Syntax Rules
      • Comments
      • Scriptlets
      • JSP Implicit Objects
      • Expressions
      • Directives
        • @page directive
        • @include directive
      • Declarations
  • Model-View-Controller (MVC)
    • Interactions
    • Model, View, Controller
      • Advantages of MVC
    • Model 1 and Model 2
    • Model 1 Disadvantages
    • Model 2
      • Controller = Servlet
      • View = JSP
      • Model = JavaBeans, EJBs, Web Services, Spring, Database Entities, etc.
    • Redirects and Forwards
      • Servlet Redirects
      • JSP Redirects
      • Redirect Side Effects
      • Servlet Forwards
      • Forward and Include Side Effects
      • Redirect versus Forward
  • JSP Tags
    • Overview
      • Standard Tags, JSTL Tags, Custom Tags
      • Tag Syntax
      • Motivation for Tags
    • Accessing JavaBeans
      • JavaBeans review
      • sp:useBean
        • Purpose
        • Id Attribute
        • Scope Attribute
        • Class Attribute
        • Type Attribute
        • Relationship to Accessing the Scopes Directly
      • jsp:getProperty
        • Purpose
        • Name Attribute
        • Property Attribute
        • Relationship to Using Expressions or Scriptlets Instead
      • jsp:setProperty
        • Purpose
        • Name Attribute
        • Property Attribute
        • Setting Properties from Request Parameters
        • Relationship to Using Scriptlets Instead
      • Forwards and Includes
        • jsp:include
          • Contrast with @include directive
          • Relationship to RequestDispatcher.include()
        • jsp:forward
          • Relationship to RequestDispatcher.forward()
  • JSP Standard Tag Library (JSTL)
    • Overview
      • JSTL Defined
      • Tag Groups and Namespaces
      • Using JSTL
        • J2EE 1.4 vs. Java EE 5
        • @taglib Directive
    • JSP Expression Language (EL)
      • EL Moved from JSTL to JSP 2.0
      • Motivation
      • EL Expressions and Usage
      • EL Operators
      • EL Implicit Objects
      • Automatic Type Conversion and Casting
      • Resolving Access to the Scopes
    • Core Tags
      • Overview
      • c:out
      • c:set
      • c:remove
      • c:forEach
        • Using with Maps
      • c:if
      • c:choose c:when c:otherwise
      • c:url and c:param
      • c:redirect
    • Formatting Tags
      • Overview
      • fmt:formatNumber
      • fmt:formatDate
    • XML and SQL Tags
      • Overview
      • Discouraged When Using an MVC Architecture
      • XML Tags
        • Uses
      • SQL Tags
        • Uses
  • Filters
    • Overview
      • Preprocessing and Post Processing
      • Uses
      • Filter Chains
        • Chain of Command Design Pattern
    • Filter API
      • Filter Interface
        • Similarities and Differences to Servlets
        • init(FilterConfig) Method
          • FilterConfig Object
        • destroy() Method
        • doFilter() Method
      • FilterChain Object
        • Controlling Flow Through the Filter Chain
    • Configuring Filters
      • <filter> Element
      • <filter-mapping> Element
      • Configuring a Filter Chain
  • Custom Tags
    • Overview
      • Tag Libraries
      • Capabilities and Uses
      • Motivation
      • Using Custom Tags
        • @taglib directive
    • Implementing Custom Tags
      • Implementation Choices
        • Tag Files
          • Runtime Behavior
        • Tag Handlers – Simple and Classic
          • Runtime Behavior
        • Tag Library Descriptor (TLD)
      • SimpleTag Interface and SimpleTagSupport Base Class
        • doTag() Method
        • Tag Attributes
        • Tag Body Content
      • Tag Library Descriptors
        • Defining the URI
        • Defining Tags in The Library
        • Location of TLD in Deployment
  • Appendix A – Learning Resources