table of contents

Beginning and Intermediate-Level
Servlet, JSP, and JDBC Tutorials

From 2nd Edition of Core Servlets and JSP (Volume 1)

The beginning and intermediate-level tutorials on this page are based on the second edition of Marty's book Core Servlets and JavaServer Pages, and have been tested by Marty in live training courses in the US, Canada, Australia, Puerto Rico, Japan, Mexico, and the Philippines. Also see the training materials home page for advanced servlet and JSP tutorials, Jakarta Struts tutorials, Apache Tomcat tutorials, JSF tutorials, Java 5 & Java 6 tutorials, and tutorials in Chinese and Japanese.

The PDF versions of the tutorials are freely available to anyone for personal use. These versions contain the complete text of the PowerPoint slides, and are what you want if your goal is to learn or review the technology. As a courtesy, coreservlets.com also makes the original PowerPoint slides available to faculty teaching courses that do not compete with Marty's live courses. See the J2EE instructor materials page for details.

To arrange a servlet & JSP course at your organization based on these materials, contact info@coreservlets.com. These courses can be customized to use any combination of the materials on the J2EE tutorials site, and new materials can be added for specific client needs. To learn more details about the instructor, the curriculum for the live training courses, or the public course schedule, please see http://courses.coreservlets.com.

Source Code

Source code for all examples in these tutorials can be downloaded from Servlet and JSP Source Code.


Servlets & JSP: Overview and Setup

View PDF of Overview and Setup
Free for personal use.

Topics:

  • Understanding the role of servlets
  • Evaluating servlets vs. other technologies
  • Understanding the role of JSP
  • Configuring the server
  • Configuring your development environment
  • Testing the server setup

Servlet Basics

View PDF of Servlet Basics
Free for personal use.

Topics:

  • The basic structure of servlets
  • A simple servlet that generates plain text
  • A servlet that generates HTML
  • Servlets and packages
  • Some utilities that help build HTML
  • The servlet life cycle
  • Servlet debugging strategies

Handling the Client Request: Form Data

View PDF of Handling Form Data
Free for personal use.

Topics:

  • The role of form data
  • Creating and submitting HTML forms
  • Reading individual request parameters
  • Reading the entire set of request parameters
  • Handling missing and malformed data
  • Dealing with incomplete form submissions
  • Filtering special characters out of the request parameters

Handling the Client Request: HTTP Request Headers

View PDF of Handling Request Headers
Free for personal use.

Topics:

  • Reading HTTP request headers
  • Building a table of all the request headers
  • Understanding the various request headers
  • Reducing download times by compressing pages
  • Differentiating among types of browsers

Generating the Server Response: HTTP Status Codes

View PDF of HTTP Status Codes
Free for personal use.

Topics:

  • Format of the HTTP response
  • How to set status codes
  • What the status codes are good for
  • Shortcut methods for redirection and error pages
  • A servlet that redirects users to browser-specific pages
  • A front end to various search engines

Generating the Server Response: HTTP Response Headers

View PDF of HTTP Response Headers
Free for personal use.

Topics:

  • Format of the HTTP response
  • Setting response headers
  • Understanding what response headers are good for
  • Building Excel spread sheets
  • Generating JPEG images dynamically
  • Sending incremental updates to the browser

Handling Cookies

View PDF of Handling Cookies
Free for personal use.

Topics:

  • Understanding the benefits and drawbacks of cookies
  • Sending outgoing cookies
  • Receiving incoming cookies
  • Tracking repeat visitors
  • Specifying cookie attributes
  • Differentiating between session cookies and persistent cookies
  • Simplifying cookie usage with utility classes
  • Modifying cookie values
  • Remembering user preferences

Session Tracking

View PDF of Session Tracking
Free for personal use.

Topics:

  • Implementing session tracking from scratch
  • Using basic session tracking
  • Understanding the session-tracking API
  • Differentiating between server and browser sessions
  • Encoding URLs
  • Storing immutable objects vs. storing mutable objects
  • Tracking user access counts
  • Accumulating user purchases
  • Implementing a shopping cart
  • Building an online store

JSP Introduction & Overview

View PDF of JSP Introduction
Free for personal use.

Topics:

  • Understanding the need for JSP
  • Evaluating the benefits of JSP
  • Comparing JSP to other technologies
  • Avoiding JSP misconceptions
  • Understanding the JSP lifecycle
  • Installing JSP pages
  • Looking at JSP in the real world

Invoking Java Code with JSP Scripting Elements

PDF:
Invoking Java Code with JSP Scripting Elements. Free for personal use.

Topics:

  • Static vs. dynamic text
  • Dynamic code and good JSP design
  • JSP expressions
  • Servlets vs. JSP pages for similar tasks
  • JSP scriptlets
  • JSP declarations
  • Predefined variables
  • Comparison of expressions, scriptlets, and declarations
  • JSP pages in XML syntax

Source Code:
jsp-scripting.zip. Code for examples from this tutorial section, formatted as a MyEclipse project.

Controlling the Structure of Generated Servlets: The JSP page Directive

PDF:
The JSP page Directive. Free for personal use.

Topics:

  • Understanding the purpose of the page directive
  • Designating which classes are imported
  • Specifying the MIME type of the page
  • Generating Excel spreadsheets
  • Participating in sessions
  • Setting the size and behavior of the output buffer
  • Designating pages to handle JSP errors
  • Controlling threading behavior

Source Code:
page-directive.zip. Code for examples from this tutorial section, formatted as a MyEclipse project.

Including Files and Applets in JSP Pages

PDF:
Including Files & Applets in JSP Pages. Free for personal use.

Topics:

  • Using jsp:include to include pages at request time
  • Using <%@ include ... %> (the include directive) to include files at page translation time
  • Understanding why jsp:include is usually better than the include directive
  • Using jsp:plugin to include applets for the Java Plug-in

Source Code:
file-inclusion.zip. Code for examples from this tutorial section, formatted as a MyEclipse project.

Using JavaBeans Components in JSP Documents

PDF:
Using JavaBeans Components in JSP Documents. Free for personal use.

Topics:

  • Understanding the benefits of beans
  • Creating beans
  • Installing bean classes on your server
  • Accessing bean properties
  • Explicitly setting bean properties
  • Automatically setting bean properties from request parameters
  • Sharing beans among multiple servlets and JSP pages

Source Code:
beans.zip. Code for examples from this tutorial section, formatted as a MyEclipse project.

The Model View Controller (MVC) Architecture: Integrating Servlets and JSP

PDF:
The Model View Controller (MVC) Architecture. Free for personal use.

Topics:

Source Code:
mvc.zip. Code for examples from this tutorial section, formatted as a MyEclipse project.

The JSP 2 Expression Language: Simplifying MVC and Access to Java Code

PDF:
The JSP 2 Expression Language. Free for personal use.

Topics:

  • Motivating use of the expression language
  • Understanding the basic syntax
  • Understanding the relationship of the expression language to the MVC architecture
  • Referencing scoped variables
  • Accessing bean properties, array elements, List elements, and Map entries
  • Using expression language operators
  • Evaluating expressions conditionally
  • Comparing MVC pages: with and without the EL

Source Code:
el.zip. Code for examples from this tutorial section, formatted as a MyEclipse project.

Using and Deploying Web Applications

View PDF of Using and Deploying Web Applications
Free for personal use.

Topics:

  • Purpose of Web applications
  • Structure of Web applications
  • Setting up Web applications with Tomcat
  • Sharing data among Web applications