table of contents
CSAJSP/2

 

Free Online Version of Second Edition

Core Servlets and JavaServer Pages

The second edition of Core Servlets and JavaServer Pages is now available for free access in PDF. See links below. Readers of the older edition can still access the first edition here.


There is now a free online servlet and JSP tutorial based on the book. The tutorial has complete source code that has been updated to the latest servlet and JSP versions, uses Eclipse, and has exercises and exercise solutions. See http://courses.coreservlets.com/Course-Materials/csajsp2.html. Also, many (most?) new Web apps should consider using JSF 2 as a higher-level alternative to servlets and JSP. See the JSF 2 tutorial series.

If you find these free tutorials helpful, we would appreciate it if you would link to us.

Chapter 1: An Overview of Servlet and JSP Technology

Topics in Chapter:

  • Understanding the role of servlets
  • Building Web pages dynamically
  • Looking at servlet code
  • Evaluating servlets vs. other technologies
  • Understanding the role of JSP

Chapter 2: Server Setup and Configuration

Topics in Chapter:

  • Installing and configuring Java
  • Downloading and setting up a server
  • Configuring your development environment
  • Testing your setup
  • Simplifying servlet and JSP deployment
  • Locating files in Tomcat, JRun, and Resin
  • Organizing projects into Web applications

Chapter 3: Servlet Basics

Topics in Chapter:

  • 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
  • How to deal with multithreading problems
  • Tools for interactively talking to servlets
  • Servlet debugging strategies

Chapter 4: Handling the Client Request: Form Data

Topics in Chapter:

  • Reading individual request parameters
  • Reading the entire set of request parameters
  • Handling missing and malformed data
  • Filtering special characters out of the request parameters
  • Automatically filling in a data object with request parameter values
  • Dealing with incomplete form submissions

Chapter 5: Handling the Client Request: HTTP Request Headers

Topics in Chapter:

  • 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
  • Customizing pages according to how users got there
  • Accessing the standard CGI variables

Chapter 6: Generating the Server Response: HTTP Status Codes

Topics in Chapter:

  • 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

Chapter 7: Generating the Server Response: HTTP Response Headers

Topics in Chapter:

  • 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

Chapter 8: Handling Cookies

Topics in Chapter:

  • 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

Chapter 9: Session Tracking

Topics in Chapter:

  • 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

Chapter 10: Overview of JSP Technology

Topics in Chapter:

  • Understanding the need for JSP
  • Evaluating the benefits of JSP
  • Comparing JSP to other technologies
  • Avoiding JSP misconceptions
  • Installing JSP pages
  • Surveying JSP syntax

Chapter 11: Invoking Java Code with JSP Scripting Elements

Topics in Chapter:

  • Static vs. dynamic text
  • Dynamic code and good JSP design
  • The importance of packages for JSP helper/utility classes
  • JSP expressions
  • JSP scriptlets
  • JSP declarations
  • Servlet code resulting from JSP scripting elements
  • Scriptlets and conditional text
  • Predefined variables
  • Servlets vs. JSP pages for similar tasks

Chapter 12: Controlling the Structure of Generated Servlets: the JSP page Directive

Topics in Chapter:

  • 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

Chapter 13: Including Files and Applets in JSP Pages

Topics in Chapter:

  • 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

Chapter 14: Using JavaBeans Components in JSP Documents

Topics in Chapter:

  • 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

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

Topics in Chapter:

  • Understanding the benefits of MVC
  • Using RequestDispatcher to implement MVC
  • Forwarding requests from servlets to JSP pages
  • Handling relative URLs
  • Choosing among different display options
  • Comparing data-sharing strategies
  • Forwarding requests from JSP pages
  • Including pages instead of forwarding to them

Chapter 16: Simplifying Access to Java Code: The JSP 2.0 Expression Language

Topics in Chapter:

  • Motivating use of the expression language
  • Invoking the expression language
  • Disabling the expression language
  • Preventing the use of classic scripting elements
  • 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

Chapter 17: Accessing Databases with JDBC

Topics in Chapter:

  • Connecting to databases: the seven basic steps
  • Simplifying JDBC usage: some utilities
  • Using precompiled (parameterized) queries
  • Creating and executing stored procedures
  • Updating data through transactions
  • Using JDO and other object-to-relational mappings

Chapter 18: Configuring MS Access, MySQL, and Oracle

Topics in Chapter:

  • Configuring a DSN to connect to Microsoft Access
  • Installing and configuring MySQL
  • Creating databases and users in MySQL
  • Installing and configuring Oracle9i
  • Using the Database Configuration Assistant to create a database in Oracle9i
  • Manually creating a database in Oracle9i
  • Creating users in Oracle9i
  • Testing your database through a JDBC connection
  • Determining the JDBC version of your database driver
  • Setting up the example music table

Chapter 19: Creating and Processing HTML Forms

Topics in Chapter:

  • Data submission from forms
  • Text controls
  • Push buttons
  • Check boxes and radio buttons
  • Combo boxes and list boxes
  • File upload controls
  • Server-side image maps
  • Hidden fields
  • Groups of controls
  • Tab ordering
  • A Web server for debugging forms

More Information

Java

JSF (JavaServer Faces)

Servlets & JSP
Ajax, GWT, & JavaScript

Spring, Hibernate, & JPA

Struts