table of contents
MSAJSP

 

Free Online Version in PDF

More Servlets and JavaServer Pages

Note: the complete text of the second edition of Core Servlets and JavaServer Pages is also online for free access. Please see http://pdf.coreservlets.com/.


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: Server Setup and Configuration

Note: for updates to this material based on new Java and Tomcat versions, please see the coreservlets.com Apache Tomcat Tutorial.

View PDF of Server Setup and Configuration chapter
View source code for Server Setup and Configurationsource code chapter

Topics:

  • Downloading the JDK
  • Obtaining a development server
  • Configuring and testing the server
  • Deploying and accessing HTML and JSP pages
  • Setting up your development environment
  • Deploying and accessing servlets
  • Simplifying servlet and JSP deployment

Chapter 2: A Fast Introduction to Basic Servlet Programming

Note: for updates to this material based on new servlet and JSP specifications, please see Core Servlets and JavaServer Pages (JSP) (Second Edition) and the Core Servlets and JavaServer Pages (JSP) tutorials and training materials.

View PDF of A Fast Introduction to Basic Servlet Programming chapter
View source code for A Fast Introduction to Basic Servlet Programmingsource code chapter

Topics:

  • The advantages of servlets over competing technologies
  • The basic servlet structure and life cycle
  • Servlet initialization parameters
  • Access to form data
  • HTTP 1.1 request headers, response headers, and status codes
  • The servlet equivalent of the standard CGI variables
  • Cookies in servlets
  • Session tracking

Chapter 3: A Fast Introduction to Basic JSP Programming

Note: for updates to this material based on new servlet and JSP specifications, please see Core Servlets and JavaServer Pages (Second Edition) and the Core Servlets and JavaServer Pages (JSP) tutorials and training materials.

View PDF of A Fast Introduction to Basic JSP Programming chapter
View source code for A Fast Introduction to Basic JSP Programmingsource code chapter

Topics:

  • Understanding the benefits of JSP
  • Invoking Java code with JSP expressions, scriptlets, and declarations
  • Structuring the servlet that results from a JSP page
  • Including files and applets in JSP documents
  • Using JavaBeans with JSP
  • Creating custom JSP tag libraries
  • Combining servlets and JSP: the Model View Controller (Model 2) architecture

Chapter 4: Using and Deploying Web Application

Note: for updates based on the new web.xml syntax for servlets 2.4, please see tutorials and training materials from More Servlets and JSP.

View PDF of Using and Deploying Web Applications chapter
View source code for Using and Deploying Web Applicationssource code chapter

Topics:

  • Registering Web applications with the server
  • Organizing Web applications
  • Deploying applications in WAR files
  • Recording Web application dependencies on shared libraries
  • Dealing with relative URLs
  • Sharing data among Web applications

Chapter 5: Controlling Web Application Behavior with web.xml

Note: for updates based on the new web.xml syntax for servlets 2.4, please see tutorials and training materials from More Servlets and JSP.

View PDF of Controlling Web Application Behavior with web.xml chapter
View source code for Controlling Web Application Behavior with web.xmlsource code chapter

Topics:

  • Customizing URLs
  • Turning off default URLs
  • Initializing servlets and JSP pages
  • Preloading servlets and JSP pages
  • Declaring filters for servlets and JSP pages
  • Designating welcome pages and error pages
  • Restricting access to Web resources
  • Controlling session timeouts
  • Documenting Web applications
  • Specifying MIME types
  • Locating tag library descriptors
  • Declaring event listeners
  • Accessing J2EE resources

Chapter 6: A Sample Web Application: An Online Boat Shop

View PDF of A Sample Web Application: An Online Boat Shop chapter
View source code for A Sample Web Application: An Online Boat Shopsource code chapter

Topics:

  • Defining and using a larger Web application
  • The interaction among components in a Web application
  • Using sessions for per-user data
  • Using the servlet context for multiuser data
  • Managing information that is accessed by multiple servlets and JSP pages
  • Eliminating dependencies on the Web application name

Chapter 7: Declarative Web Application Security

View PDF of Declarative Web Application Security chapter
View source code for Declarative Web Application Securitysource code chapter

Topics:

  • Understanding the major aspects of Web application security
  • Authenticating users with HTML forms
  • Using BASIC HTTP authentication
  • Defining passwords in Tomcat, JRun, and ServletExec
  • Designating protected resources with the security-constraint element
  • Using login-config to specify the authentication method
  • Mandating the use of SSL
  • Configuring Tomcat to use SSL

Chapter 8: Programmatic Security

View PDF of Programmatic Security chapter
View source code for Programmatic Securitysource code chapter

Topics:

  • Combining container-managed and programmatic security
  • Using the isUserInRole method
  • Using the getRemoteUser method
  • Using the getUserPrincipal method
  • Programmatically controlling all aspects of security
  • Using SSL with programmatic security

Chapter 9: Servlet and JSP Filters

Note: for updates (especially for the ReplaceFilter), please see tutorials and training materials from More Servlets and JSP.

View PDF of Servlet and JSP Filters chapter
View source code for Servlet and JSP Filterssource code chapter

Topics:

  • Designing basic filters
  • Reading request data
  • Accessing the servlet context
  • Initializing filters
  • Blocking the servlet or JSP response
  • Modifying the servlet or JSP response
  • Using filters for debugging and logging
  • Using filters to monitor site access
  • Using filters to replace strings
  • Using filters to compress the response

Chapter 10: The Application Events Framework

View PDF of The Application Events Framework chapter
View source code for The Application Events Frameworksource code chapter

Topics:

  • Understanding the general event-handling strategy
  • Monitoring servlet context initialization and shutdown
  • Setting application-wide values
  • Detecting changes in attributes of the servlet context
  • Recognizing creation and destruction of HTTP sessions
  • Analyzing overall session usage
  • Watching for changes in session attributes
  • Tracking purchases at an e-commerce site
  • Using multiple cooperating listeners
  • Packaging listeners in JSP tag libraries

Chapter 11: New Tag Library Features in JSP 1.2

Note: for updates for JSP 2.0, please see tutorials and training materials from More Servlets and JSP.

View PDF of New Tag Library Features in JSP 1.2 chapter
View source code for New Tag Library Features in JSP 1.2source code chapter

Topics:

  • Converting TLD files to the new format
  • Bundling life-cycle event listeners with tag libraries
  • Checking custom tag syntax with TagLibraryValidator
  • Using the Simple API for XML (SAX) in validators
  • Handling errors with the TryCatchFinally interface
  • Changing names of method return values
  • Looping without creating BodyContent
  • Declaring scripting variables in the TLD file

More Information

Java

JSF (JavaServer Faces)

Servlets & JSP
Ajax, GWT, & JavaScript

Spring, Hibernate, & JPA

Struts