Advanced Servlet and JSP Tutorials

Interested in training from the author of these tutorials? See the upcoming public J2EE training courses in Maryland (co-sponsored by Johns Hopkins Engineering for Professionals, or contact hall@coreservlets.com for info on customized courses at your location.


The advanced tutorials on this page were originally based on Marty's book More Servlets and JavaServer Pages, but have evolved significantly to incorporate new technologies and approaches. They have been tested by Marty in live training courses in the US, Canada, Australia, Puerto Rico, Japan, Mexico, and the Philippines. Click on a topic below to get the detailed tutorial, download the source code, or try out exercises on the topic. Also see the beginning and intermediate servlet and JSP tutorials for topics like setting up Eclipse, deploying apps, servlet basics, cookies, session tracking, JSP scripting, file inclusion, MVC, the JSP expression language, and much more. In addition, the training materials home page has tutorials on many other Java-related topics. The PDF versions of the tutorials are freely available to anyone for personal use. As a courtesy, we also make the original PowerPoint slides available to university faculty for no charge. 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.

If you find these free tutorials helpful, we would appreciate it if you would link to us. Send corrections or feedback on any tutorial to hall@coreservlets.com.


Servlets and JSP: A Review of the Basics

Using and Deploying Web Applications

  • This tutorial section in PDF.
  • Topics covered:
    • Purpose of Web applications
    • Structure of Web applications
    • Setting up Web applications with Tomcat
    • Sharing data among Web applications

Controlling Web Application Behavior: The Deployment Descriptor web.xml

Declarative Web Application Security

Programmatic Web Application Security

  • This tutorial section in PDF.
  • Source code of examples in this section:
    • hotdotcom-internal.zip. Web app used for the first set of examples in this section (using isUserInRole for container-managed security with some programmatic security). Bundled as an Eclipse project.
    • stocks.zip. Web app used for the second set of examples in this section (using pure programmatic security and tracing SSL info). Bundled as an Eclipse project.
    • tomcat-users.xml. Simple Tomcat-specific username/password/role file. For real apps, always use an encrypted file: this is just for testing. Drop this file in the Tomcat "conf" folder. If you are running Tomcat manually, this is tomcat-install-dir/conf. If you are running Tomcat within Eclipse, this is something similar to eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/conf. In this section, this file applies only to the hotdotcom-internal app, not the stocks app.
  • Exercises to reinforce the concepts in this section.
  • Exercise solutions. Bundled as an Eclipse project.
  • Topics covered:
    • Problems with declarative security
      • The advantages of declarative security usually outweigh the disadvantages. But not always.
    • Combination security: mixing server-managed and servlet-managed (programmatic) security
      • Solve one of the drawbacks of declarative security with only a little bit of extra work.
    • Pure programmatic security
      • Solve the other drawbacks, but with a very lot of extra work.

Servlet and JSP Filters

The Web Application Life-Cycle Events Framework

Creating Custom JSP Tag Libraries: The Basics

Creating Custom JSP Tag Libraries: Advanced Topics

The JSP Standard Tag Library (JSTL)

Accessing Databases with JDBC

This section gives an introduction to the Java DataBase Connectivity (JDBC) library, the relatively simple but low-level database library that is built into Java SE.

The Spring Framework: Overview and Setup

The Spring sections are taken from the longer coreservlets.com Spring Framework tutorial.

  • This tutorial section in PDF.
  • Source code of examples in this section:
    • spring-intro.zip. Sample code used in this section, bundled as an Eclipse project.
    • spring-blank.zip. Basic starting point for Spring apps: an Eclipse project with the required JAR files, a blank applicationContext.xml, the Spring IDE project nature, and nothing else. Copy and rename this when you start new Spring-based apps.
  • Topics covered:
    • What is Spring?
      • And why use it?
    • Main Spring modules
      • Dependency injection
      • AOP
    • Configuring apps to use Spring
      • And Eclipse plugin support
    • Simple example

The Core Spring Module: Defining Beans and Dependency Injection

The Spring sections are taken from the longer coreservlets.com Spring Framework tutorial.

Using Spring in Web Apps and JSF

The Spring sections are taken from the longer coreservlets.com Spring Framework tutorial.

  • This tutorial section in PDF.
  • Source code of examples in this section:
  • Topics covered:
    • Servlet/JSP apps
      • Creating a Dynamic Web Project in Eclipse
      • Adding Spring support
      • Adding Spring JAR files and bean definition file
      • Registering listeners in web.xml
      • Loading bean definition file
      • Getting bean instances
    • JSF apps
      • Creating a JSF Project in Eclipse
      • Adding Spring support
      • Defining beans in applicationContext.xml
      • Defining beans in faces-config.xml

PowerPoint Files for University Faculty

The PDF files in this tutorial contain the complete text of the original PowerPoint files, so if your goal is learning this technology, just stick with this tutorial. However, as a service to instructors teaching full-semester courses at accredited universities, coreservlets.com will release the original PowerPoint files for free. Please see the instructor materials page for details.

More Information

Java

JSF (JavaServer Faces)

Servlets & JSP
Ajax, GWT, & JavaScript

Spring, Hibernate, & JPA

Struts