SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Since being introduced in 1999, JavaServer Pages (JSP) have become a popular and important technology for building dynamic, interactive, content-rich Web sites. JavaServer Pages, Second Edition is a hands-on guide to working with JSP, offering the easiest and most efficient ways for non-programmers and Web designers to create sophisticated, dynamic sites. Programmers can also utilize this book to independently create new dynamic components. This second edition covers the latest release of the JSP specification (2.0), many standard extensions to JSPs, and a number of best practices that have been developed since the publication of the first edition.
This book also offers overviews of some related technologies, including:
JavaServer Pages, Second Edition contains all the information necessary to start writing JSP--for anyone who has a computer and can write HTML. It includes practical, Java-based techniques for maintaining and personalizing information-rich Web sites, as well as examples based on Jakarta Struts, the new JSP toolkit. Recent updates provide a number of new tools and techniques that will allow readers to get the most productivity from JSPs, with the least amount of effort.
Also included is a CD-ROM containing everything you need to get started. The tools, which are free, open-source, stable, secure, and run on pretty much every platform, are powerful enough to serve even a mid-sized Web site without problems. Contents of the CD-ROM include: Tomcat, the open-source reference implementation of the latest JSP and Servlet specification; useful libraries such as the JavaServer Pages Standard Tag Library (JSTL) and Struts; Hsqldb, a self-contained, 100 percent pure Java database; all the code examples from the book; and a number of Java beans, providing ready-to-use components for many of the tasks frequently needed on a dynamic Web page.
The Standard Tag Library in the JSP Specification
Download the Sample Chapter related to this title.
Preface.
Acknowledgments.
1. Introduction.
A Brief History of the Web.
Basic Dynamic Page Generation.
Solving CGI Problems.
Speeding up CGI.
Separating HTML from Code.
Servlets and JavaServer Pages.
Welcome to Java News Today.
Trying the Examples.
Removing Text from a JSP.
JSP Errors.
Including Text in a JSP.
The Phases of a JSP.
Creating Custom Error Pages.
Java News Today.
Summary and Conclusions.
Tags Learned in This Chapter.
Splitting Big Tasks into Manageable Pieces.
Defining Beans.
JavaBean Tags.
Getting a Property.
Setting Properties.
Making Data Available Throughout an Application.
The Page Scope.
The Request Scope.
The Session Scope.
The Application Scope.
Special Actions When Beans Are Created.
Making Beans Last Forever.
Java News Today and Beans.
Future Directions.
Summary and Conclusions.
Tags Learned in This Chapter.
Tag Libraries.
Tags with Bodies.
Dynamic Attributes in Tags.
Displaying Expressions.
Formatting Output.
Compound Data in the Expression Language.
Repeating a Section of a Page.
Optionally Including Sections of a Page.
Browser Detection.
Combining Tags.
Selecting among Multiple Choices.
Summary and Conclusions.
Tags Learned in this Chapter.
The Beans.
The Header.
The Left-Hand Navigation.
The Login Page.
The Quiz Result Page.
The Section Page.
The Article Page.
The Remaining Pages.
Summary and Conclusions.
Tags Learned in this Chapter.
A Quick Introduction to Databases.
A Language for Databases.
Using SQL Directly from JSPs.
Inserting Data from JSPs.
SQL and Beans.
Summary and Conclusions.
Tags Learned in This Chapter.
Designing the Tables.
Adding Articles.
User Pages.
Other User Preferences.
Advertising.
Summary and Conclusions.
A Brief Introduction to XML.
Using XML in JSPs.
Selecting Data from an XML Document.
Processing XML in JSPs.
Formatting XML.
Java News Today and XML.
Summary and Conclusions.
Tags Learned in this Chapter.
Expressions.
Types.
Storing Values.
Method Calls.
Conditionally Evaluating Code.
Evaluating the Same Code Multiple Times.
Grouping Code.
Handling Errors.
Modeling a Problem with Objects.
Objects in Java.
Building Objects from Classes.
Sometimes Nothing Is Something.
Building Classes from Other Classes.
Interfaces.
Creating Groups of Classes and Interfaces.
Using Java in JSPs.
Database Access from Java.
Summary and Conclusions.
How Beans Are Implemented.
Automatic Type Conversion.
How Beans Work.
Bean Serialization.
Events.
Special Events.
Bean Errors.
Summary and Conclusions.
The Servlet Life Cycle.
The Servlet Class Hierarchy.
More about Requests.
More about Responses.
Convenience Methods.
Servlet Events.
Forwarding and Including Requests.
Using Scopes from Servlets.
Using Beans from Servlets.
The JSP Classes.
Intercepting Requests.
Summary and Conclusions.
Some Common Controller Tasks.
Support for Controllers: Struts.
Using Struts.
Providing Security.
Struts and JNT.
Summary and Conclusions.
The Tag Life Cycle.
Tags without Bodies.
Tags with Bodies.
Using the Expression Language.
JSPs as Custom Tags.
Summary and Conclusions.
Declaring Variables and Methods.
Extending Different Classes.
Returning Other Kinds of Data.
Threads.
Avoiding Thread Problems.
Using Threads.
Advanced Error Handling.
Summary and Conclusions.
Built-in Tags.
Core Tags.
Format, Parsing, and Internationalization Tags.
SQL Tags.
XML Tags.
Layout of the Directories.
The Web.xml File.
This is a book about how to create dynamic, interactive web sites using an exciting and powerful technology called JavaServerPages. As the name implies, this technology is based on the Java programming language and inherits many of the language's features and benefits. Most notably, Java makes JSPs available on almost every kind of computer and operating system, and certainly all those in common use.
JavaServer Pages are now a mature and stable technology, already in use in thousands of companies. But maturity has certainly not lead to stagnation! Recently a new version of the JSP specification has been released, bringing new capabilities and possibilities. In addition, several companion technologies have been developed which augment the fundamental specification. The new specification, as well as the most important of these associated technologies, are all covered in this book. Throughout this book effort has been made not only to show the capabilities of all these tools, but also to discuss how they can best be used.
One of the most important features of JavaServer Pages is how easy they are to use. Anyone who is reasonably comfortable with HTML can learn to write JavaServer Pages by using a few simple tags which may do very sophisticated things behind the scenes, along with small packages of code called JavaBeans. This allows for a very productive working relationship between HTML experts who build pages, and Java programmers who build beans and new tags.
Both kinds of developer will find material of interest in this book. Chapter 1 gives a brief history of the web, in order to set JSPs in context and clarify what they are, how they work, and why they work that way. Chapter 2 then introduces some of the simpler features of JSPs and shows just how easy the transition from HTML to JSP is.
The next two chapters introduce the two vital technologies that give JSPs their enormous power and flexibility--JavaBeans in Chapter 3 and custom tags in Chapter 4. These are presented as page authors will use them, components that hide all the complexities of Java behind simple interfaces that can be combined and used in limitless ways. Chapter 5 then uses beans and tags to build a fully functional web site!
One of the great benefits of JSPs is that they make it possible for pages to interact with complex systems. A very common such system is a database. Chapter 6 introduces database concepts, and discusses easy ways in which a page author can access data. Chapter 7 then uses this information to expand the utility of the site built in Chapter 5.
XML is an increasingly important technology, and JSPs are already well-equipped to work with XML. This is covered in Chapter 8.
The first 8 chapters comprise a logical first half of the book, dealing with the myriad things page authors can do with JSPs without knowing anything about Java. The remainder of the book delves under the hood to explain how all this is accomplished, and how Java programmers can extend the capabilities of JSPs. For readers who are not yet familiar with Java, Chapter 9 introduces the language.
From there the book covers the process of creating new beans in Chapter 10. Chapter 11 covers a technology called servlets that underlies JSPs. This information is then used in Chapter 12 to talk about controllers, Java code that helps pieces of a web site work together simply and cleanly. Chapter 13 then discusses how to use Java to create new tags, and finally Chapter 14 covers a few remaining advanced topics.
Readers who are not interested in programming will get the most out of this book by reading Chapters 1 through 9, which comprise a complete course on how to use JSPs, beans, tags, and related technologies to build just about any web site imaginable. At that point such readers may wish to learn a little Java from Chapter 9 and then proceed on through the rest of the book in order to better understand how everything works.
On the other hand, readers who already know Java but who may not be familiar with either JSPs, the new features added as part of the latest specification, or related technologies will want to move quickly through Chapter 2 to get a feel for JSP syntax, and then go through Chapters 3 and 4 to see how JSPs interface with Java via tags and beans. Programmers may then wish to proceed to Chapter 10 to see how new beans are created, and from there through the second half of the book in order to understand servlets and tags.
Finally, as amazing as it may seem, there is absolutely no cost to developing and deploying JSPs! There is no need to buy a special server or particular hardware or operating system. All the tools needed, and many others, have been released for free by the Apache group. The CD-ROM accompanying this book contains these tools, as well as all the examples from the book.
It is my sincere hope that this book in conjunction with these tools will help you get the most out of this revolutionary new technology for building exciting, compelling web sites.
Download the Index
file related to this title.