Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Books

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
Print Button
 

Bookshelf Index

Core Servlets and JavaServer PagesTM
by Marty Hall

(June 02, 00)

Introduction | Chapter 7 PDF | Chapter 14 PDF

Core Servlets and Java Server Pages Here are two chapters excerpted from Core Servlets and Java Server Pages by Marty Hall, and published by Sun Microsystems Press/Prentic Hall PTR. These are, Chapter 7, Generating the Server Response: HTTP Response Headers, and Chapter 14, Creating Custom JSP Tag Libraries.

A Note from the Author

In the past year, there has been a virtual stampede toward server-side applications among developers, server vendors, and the authors of the Java platform specifications. So much so, that the technology is rapidly becoming the standard tool for building dynamic web sites, and connecting web front ends to databases and applications on a server.

In mid-1999, I put together a short servlet and JSP tutorial with a few dozen examples, put it on the Web, and tried out the material in a couple of my courses. The response was overwhelming. After only a few months, I was getting several thousand visitors a day to the tutorial along with a myriad of requests to expand the coverage of the material. I started writing. Core Servlets and JavaServer PagesTM is the result.

Core Servlets and JavaServer Pages is aimed at serious software developers. It is a hands-on book aimed at helping programmers who are already convinced of the need for dynamic web sites, and who want to get started building them right away. In showing how to build these sites, I try to illustrate the most important approaches and warn you of the most common pitfalls. Along the way, I include plenty of working code: hundreds of documented examples, all of which are freely available online for unrestricted use.

It is not a book that skims dozens of technologies at a high level. Although I don't claim that it is a definitive reference on every technology it touches on, if the book covers a topic, it does so in enough detail for you to sit down and start writing real programs. The one exception to this rule is the Java programming language itself. Although I don't assume any familiarity with server-side programming, you need to be familiar with the basics of Java language development.

Core Servlets and JavaServer Pages is divided into three parts: Servlets, JavaServer Pages, and Supporting Technologies.

Part I covers servlet development with the 2.1 and 2.2 specifications. Although version 2.2 (along with JSP 1.1) is mandated by the Java 2 Platform, Enterprise Edition (J2EETM), many commercial products are still at the earlier releases, so it is important to understand the differences. Also, although servlet code is portable across a huge variety of servers and operating systems, server setup and configuration details are not standardized. So, I include specific details for Apache Tomcat, Sun's JavaServerTM Web Development Kit (JSWDK), and the Java Web ServerTM. The first online chapter presented here is from this section: Chapter 7 Generating the Server Response: HTTP Response Headers. This chapter includes the following topics:
  • How (and why) you set HTTP response headers from servlets
  • The purpose of each of the HTTP 1.1 response headers
  • Example 1: Persistent servlet state and auto-reloading pages
  • Example 2: Using persistent HTTP connections
  • Example 3: Dynamically generating GIF images

Part II covers the use of JavaServer Pages version 1.0 and 1.1. Topics include JSP scripting elements, structuring generated servlets, including files and applets in JSP pages, using JavaBeansTM technology with JSP, creating custom tag libraries, and integrating servlets and JSP. The ability to define your own tags is the important new contribution of JSP 1.1, but the process is poorly understood. Chapter 14, Creating Custom Libraries, is presented online here. Topics in the chapter include:
  • The components that make up a tag library
  • Defining a basic tag
  • Assigning attributes to tags
  • Including the tag body
  • Optionally including the tag body
  • Manipulating the tag body
  • Including or manipulating the tag body multiple times
  • Using nested tags

Part III covers three topics that are commonly used in conjunction with servlets and JSP: HTML forms, applets talking to servlets, and database access with JDBC technology.

The appendix provides a handy summary of servlet and JSP syntax and usage.
For more information see:

  • Core Servlets and JavaServer Pages home page.
  • Source code archive. All code from book available free for unrestricted use.
  • Complete table of contents. Also available in PDF.
  • Index. Adobe acrobat (PDF) format.
  • Core Servlets and JavaServer Pages at amazon.com.
  • Free examination copies for instructors.

    Introduction | Chapter 7 PDF | Chapter 14 PDF

    About the Author

    Marty Hall is a Senior Computer Scientist at the Johns Hopkins University Applied Physics Lab, and teaches JavaTM and web programming in the Johns Hopkins part-time graduate program in Computer Science, and for various industry short courses. He is the author of the best-selling book "Core Web Programming."

    Reader Feedback

    Tell us what you think of this book excerpt.

     Very worth reading  Worth reading  Not worth reading

    If you have other comments or ideas for future technical content, please type them here:


  • Print Button
    [ This page was updated: 27-Sep-2000 ]
    Products & APIs | Developer Connection | Docs & Training | Online Support
    Community Discussion | Industry News | Solutions Marketplace | Case Studies
    Glossary | Feedback | A-Z Index
    For more information on Java technology
    and other software from Sun Microsystems, call:
    (800) 786-7638
    Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
    Sun Microsystems, Inc.
    Copyright © 1995-2000 Sun Microsystems, Inc.
    All Rights Reserved. Terms of Use. Privacy Policy.