Home > Store

Callaway:Inside Servlets _p2, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Callaway:Inside Servlets _p2, 2nd Edition

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2001
  • Dimensions: 7-1/4" x 9-1/4"
  • Pages: 920
  • Edition: 2nd
  • Book
  • ISBN-10: 0-201-70906-6
  • ISBN-13: 978-0-201-70906-3

Java servlets are the killer app for server-side programming. They represent the first cross-platform solution for server-side development that delivers the performance developers require -- and they've been incorporated into nearly every leading Web server platform. Inside Servlets, Second Edition teaches developers all they need to build robust, powerful servlets with Sun's new Servlets 2.2 API. It combines detailed, real-world projects, a comprehensive API reference, and extensive new coverage of crucial topics ranging from security to database integration. The book starts with a brief, crystal-clear introduction to servlet technology and architecture -- and then dives into the sophisticated techniques Java developers need to make the most of their servlets. Dustin Callaway provides a complete development framework for building Internet applications, as well as three start-to-finish sample servlets. He also offers outstanding, code-rich explanations of key techniques such as state/session management, cookies, thread-safe servlets, JDBC database access, cross-request communications, request forwarding, and partitioning. This Second Edition adds extensive coverage of deployment, servlet security and authentication, internationalization, JavaServer Pages, and more.

Downloads

CD Contents

Untitled Document This file contains the CD Contents from the book Inside Servlets, Second Edition

Sample Content

Table of Contents



Foreword.


Preface.


Introduction.

I. INTRODUCTION TO WEB DEVELOPMENT.

Internet Basics 3.

Networks. Protocols. TCP/IP. Brief History of the Internet. Internet Addresses. Ports. Socket. Name Resolution. Firewalls. Protocol Tunneling. Proxy Servers. Internet Standards. Summary.

2. Web Basics.

Brief History of the Web. URLs. Web Browsers. Web Servers. Common Gateway Interface. Summary.

3. Beyond Web Basics.

HTTP. MIME. HTML Forms. Summary.

II. INTRODUCTION TO SERVLETS.

4. Why Servlets?

What Is a Servlet? Where Do Servlets Fit In? What Can Servlets Do? Why Are Servlets Better Than CGI? NSAPI/ISAPI. Summary.

5. Servlet Basics.

Basic Servlet Structure. Servlet Lifecycle. Servlet Reloading. Dissecting Two Sample Servlets. Summary.

6. Servlet API Basics.

HttpServlet. Class. GenericServlet. Class. ServletRequest Interface. HttpServletRequest Interface. ServletResponse Interface. HttpServletResponse Interface. Summary.

7. Writing Your First Servlet.

Servlet Requirements. Main Page. View Bulletins. Post Bulletin Page. Save Bulletin Page. Complete Bulletin Board Servlet. Summary 193

8 Running Servlets.

Apache Tomcat. Jrun. ServletExec. Resin. Summary.

9. Debugging Servlets. AHEADS = Servlet Debugging Process. Jbuilder. Forte for Java. VisualCafé. Summary.
10. Beyond Servlet API Basics.

ServletInputStream Class.ServletOutputStream Class. ServletConfig Interface. ServletContext Interface. ServletException Class. UnavailableException Class. Summary.

III. ADVANCED SERVLET CONCEPTS.

11. Writing Thread-Safe Servlets.

What Is Thread Safety? Synchronization. Service, doGet, and doPost Local Variables. SingleThreadModel Interface. Background Threads. Summary.

12. HTTP Redirects.

What Is an HTTP Redirect? HTTP Header Syntax for a Redirect. Sending a Redirect from a Servlet. Load-Balancing Servlet Using HTTP Redirects. Summary.

13. Cookies.

What Is a Cookie? HTTP Header Syntax for a Cookie. Setting Cookies with the Servlet API. Summary. @CHAPTER 14. State and Session Management.

What Is a Stateless Protocol? What Is a Session? State and Session Management Defined. State and Session Management Methods. Session Management with the Servlet API. Session Listeners and Events. Summary.

15. Request Forwarding, Server-Side Includes, Servlet Chaining.

Using the RequestDispatcher Object. Server-Side Includes. Servlet Chaining. Summary.

16. Database Access with JDBC.

JDBC Architecture. Accessing a Database. Basics. Advanced Database Concepts. Database Connection Pooling. Introduction to the MySQL Database. Summary.

17. Security.

Basic Authentication. Form-Based Authentication. Digest Authentication. Secure Sockets Layer. Summary.

18. JavaServer.

Introduction to JSP. Scope Rules. Implicit Objects. Directives. Scripting Elements. Comments. Actions. CCustom Tag Libraries. Using JSP and Servlets Together. Summary.

19. Packaging and Deployment. @AHEADS Building a Web Application Archive. Deploying on Apache Tomcat. Deploying on Jrun. Deploying on ServletExec. Summary.
20. Servlet Troubleshooting.

Protocol Explorer Utility. Diagnostics Servlet. Summary.

IV. SAMPLE SERVLETS.

21. Form Mailer Servlet.
22. File Upload Servlet.
23. Servlet Template Framework.

Building a Web Application. Inside the Template Server. Guest Book Sample Application.

V. SERVLET API QUICK REFERENCE.

24. Javax.Servlet Package.

Interface RequestDispatcher. Interface Servlet. Interface ServletConfig. Interface ServletContext. Interface ServletRequest. Interface ServletResponse. Interface SingleThreadModel. Class Generic Servlet. Class ServletInputStream. Class ServletOutputStream. Class ServletException. Class UnavailableException

25. Javax.Servlet.http Package. Interface HttpServletRequest. Interface HttpServletResponse. Interface HttpSession. Interface HttpSessionBindingListener. Class Cookie. Class HttpServlet. Class HttpSessionBindingEvent. Class HttpUtils.
26. Servlet API 2.3 Update.

Filtering. Application Lifecycle Events. Shared Library Dependencies. New Error and Security Attributes. Welcome Files. New Classes, Interfaces, and Methods.

VI. APPENDICES.

A: Common Well-Known Port Assignments.
B: Java Port Scanner.
C: The Internet Standardization Process.
D: URL Syntax for Common Protocols.
E: Meaning of URL Special Characters.
F: US-ASCII Encoding for Unsafe URL Characters.
G: Java HTTP Server.
H: HTTP Response Status Codes.
I: Common HTTP Request Header Fields.
J: Deployment Descriptor DTD.
K: Common MIME Types.
L: printStackTrace to String.
M: Servlet API Class Hierarchy Diagram.
Index. 0201709066T04272001

Preface

Future generations will likely rank the Internet alongside the printing press, the airplane, and the personal computer as one of the most revolutionary technologies in history. After seemingly lying dormant for more than two decades, the Internet has emerged from obscurity to capture the interest and imagination of people around the world. One of the primary factors driving this phenomenon is the astounding popularity of the World Wide Web. Globally accessible via the Internet, the Web has forever changed the way information is published and distributed. The first goal of this book is to familiarize you with the underlying technologies that drive the Internet and the World Wide Web.

The Java programming language is another emerging technology whose potential is just beginning to be recognized. Due to its platform-independent nature, standard network interfaces, and many other advantages, Java is the ideal language for Internet programming. Although initially popularized by applets capable of running on any client, the true power of Java is being realized on the server. Among other things, server-side Java allows developers to build dynamic Web sites using a powerful, object-oriented language that is completely portable across virtually all operating systems and hardware. By writing programs for the Java platform, you are in essence developing applications for all existing platforms--from mobile phones to mainframes and everything in between. This kind of portability and cross-platform functionality isunprecedented.

The Internet relies on open standards to ensure that all clients have equal access to the vast amount of information it provides. Similarly, standards are essential to the advancement of the Java platform. Sun Microsystems, Inc., in cooperation with many industry partners and other interested parties, has created a standard for developing server-side Java programs that extend andenhance the functionality of the server. Known as the Java Servlet API, this standard ensures that all servlets will run properly on all platforms for which a Java virtual machine is available.

By conforming to the Servlet API specification, you can guarantee that all of your server-side programs will run on any platform that fully supports Java. After presenting Web development fundamentals, the second and primary goal of this book is to provide an in-depth understanding of Java servlets and the Servlet API through discussion and example.

What's New in This Edition

This edition of Inside Servlets both revises and expands upon the first edition. Primarily, the bulk of the revisions update the text and source code to conform to version 2.2 of the Java Servlet Specification. In addition to conforming to the new specification, the breadth and depth of the book has been greatly expanded. The second edition of Inside Servlets provides comprehensive coverage of several new topics, including security, JavaServer Pages, packaging and deployment, and servlet troubleshooting. The chapter on database access has also been greatly expanded. Finally, this edition includes improved sample servlets, an updated quick reference section, and a complete review of version 2.3 of the Java Servlet Specification.

Intended Audience

In general, this book was written for anyone interested in using server-side Java to build dynamic, data-driven Web sites or other networked applications. To this end, Inside Servlets: Server-Side Programming for the Java(TM) Platform, Second Edition, presents an in-depth review of the Servlet API as well as advanced programming concepts essential for successful servlet development. These concepts include writing thread-safe servlets, session management, database access, and security.

More specifically, the book is intended for programmers and consultants who desire to learn Web development fundamentals in addition to server-side Java programming. Much of this audience likely consists of current client/server programmers. After all, in an increasingly Internet-centric world, many client/server programs are being redeveloped as Web applications. This decisionis often driven by the fact that Web applications offer significant distribution and maintenance advantages over traditional client/server systems.

Because Java servlets may represent your first foray into Web development, the first part of the book is dedicated to teaching the basics of the Internet and the World Wide Web. Although basic Web concepts are presented, the Java programming language is not taught. This book assumes a basic knowledge of object-oriented programming and the Java language. If you are not familiar with Java, I recommend reading the Java primer in Java in a Nutshell by David Flanagan. This primer is especially well suited to C programmers. Another personal favorite for learning about Java is Thinking in Java by Bruce Eckel. If you do not already know Java, you may want to have one of these books available as a reference while reading this book.



0201709066P04272001

Index

AAbsolute URLs, 27, 28, 308, 328, 329
Accept header field, 47
Access control list, 440
Accessor methods, 535, 537
ACTION attribute, 60-61
Actions, 481, 528-545, 576
   jsp:forward, 530-531
   jsp:getProperty, 534, 539-541
   jsp:include, 528-530
   jsp:plugin, 531-533
   jsp:setProperty, 534, 541-545
   jsp:useBean, 534, 538-539
Active Server Pages (ASPs), 35, 488, 492
addCookie() method, 148, 317, 321
   HttpServletResponse interface, 745
   HttpServletResponseWrapper class, 803
addDateHeader() method, 151
   HttpServletResponse interface, 745
   HttpServletResponseWrapper class, 803
addHeader() method, 152
   HttpServletResponse interface, 745
   HttpServletResponseWrapper class, 803
addIntHeader() method, 153
   HttpServletResponse interface, 746
   HttpServletResponseWrapper class, 803
Addresses
   Internet, 3, 13-15
   node, 4
Adelman, Leonard, 470
Advanced Research Projects Agency (ARPA), 12
AIX, 222
Algorithms
   asymmetric key, 466
   Diffie-Hellman, 470
   encryption, 465
   hashing, 462
   one-way functions, 469-470
   RSA cryptosystem, 470
Aliases, 204, 224, 227, 232
Allaire Corporation, xvi, 195, 211, 231, 232, 235
   Cold fusion, 488
   JRun, 584
   servlet debuggers from, 259
ALLOWS header, 118
ALT attribute, 34
ALTER TABLE command, 385
Apache Jakarta project, 35, 196, 231. See also Apache Tomcat
Apache Software Foundation, xvi, 196, 231
Apache Struts project, 574
Apache Tomcat, xvi, 35, 74, 77, 89, 105, 195, 196-211, 231, 259, 492, 493, 582-583, 592, 673
   authentication realm display, 448
   basic authentication with, 439, 446-454
   beta version 4.0, 767
   directories, 200
Apache Tomcat (cont.)
   error page with examples Web application, 461
   form-based authentication with, 458-461
   4.x, 767
   installing, 196-199
   and JavaServer Pages, 488-489
   login page included with examples Web application, 460
   output produced by, at startup, 583
   server output indication, 198
   servlet names, initialization parameters, servlet mappings, 204-206
   and servlet reloading, 88
   3.1, 449-450, 458-459
   3.2, 459
   3.x, 767      
   user information determined from basic authentication data, 449
   WAR file for examples Web application, 581, 582
   Web applications, 199-203
   Welcome Page, 198
Apache Web Server, xvi, 35, 74, 195, 199, 212, 231, 440
   Resin as servlet container for, 227
   ServletExec support for, 222
Apostrophes, 29, 401-402
Applets, xv, 33, 39, 72, 75, 81
Application event listeners, 775-777
   configuration, 777
   interfaces, 775
application implicit object, 496, 497-498
Application lifecycle events, 774-778
Application scope objects, 496, 575
Architecture
   JDBC, 373-378
   template server, 694-696
ARPA. See Advanced Research Projects Agency
ASPs. See Active Server Pages
Asymmetric key algorithm, 466
ATG Dynamo Application Server, 74
attributeAdded() method
   HttpSessionAttributesListener, 788
   ServletContextAttributesListener, 786
attributeRemoved() method
   HttpSessionAttributesListener, 788
   ServletContextAttributesListener, 786
attributeReplaced() method
   HttpSessionAttributesListener, 789
   ServletContextAttributesListener, 786
Attribute values
   dynamic, 545-546
Authenticated users
   information retrieval about, 450-451
   methods returning information about, 450
Authentication, 77, 137, 324. See also Security
   basic, 439-454, 478, 479
   challenge, 440, 444
   and database connection, 380
   digest, 439, 462-465, 478, 479
   form-based, 439, 454-461, 478,
479
   HTTP, 45
   and MVC design pattern, 574
Authorization, 447
Autocommit mode, 403
autoFlush attribute, 503-504
AUTO_INCREMENT statement, 383
Automatic flush option, 503BBackground threads, 281, 292-296, 297
"Bad Request" message, 110, 111, 112, 113, 117
Base64, 57
Base64 decoder, 445
Base64 encoding, 442, 462
BaseServlet class, 675, 697
Basic authentication, 478, 479
   introduction to, 439-441
   servlet creation, 441-445
   using with Tomcat, 446-454
BasicAuthServlet, 452
   user authentication, 453
BEA WebLogic Application Server, 74
Berkeley UNIX, 17
Berners-Lee, Tim, 23, 24, 39
Binary data storage, 399
Binary Large Objects, 374, 399
BLOBs. See Binary Large Objects
Bluestone Sapphire Web, 74
BodyContent object
   methods supported by, 561
BodyTag interface, 550
BodyTagSupport class, 551, 556, 560, 561, 563
Borland Software Corporation, 233, 235
Boundary markers, 653, 657
Breakpoints, 243
   adding, 242
   Forte for Java, 247, 250, 251
   VisualCafe, 258, 259
Broadcast messages, 4n1, 10n3, 11
Browsers, 24, 32-34, 464. See also Web browsers
buffer attribute, 504-505
BufferedReader class, 133, 177
Buffers/buffering, 157, 504
Bulletin Board servlet, 161, 194, 209, 210
   complete source code for, 186-193
   functionality of, 161-162
   mainpage of, 162-169
Business transaction security, 439
Bytecode compilation, 73CC, 38
CallableStatement object
   and stored procedures, 407
Callable statements, 374
CAs. See Certificate authorities
Cascading Style Sheets, 59
Case-sensitivity
   and URLs, 26
catch block, 173, 175, 178, 185
Caucho Technology, 195, 227, 228, 232
CDATA elements, 485
CERN (European Laboratory of Particle Physics), 23-24
Certificate authorities (CAs), 467, 479
CGI (Common Gateway Interface), xv, 35, 37-38, 71, 73
   fast, 80, 82
   servlet advantages over, 78-80
CGI environment variable
   and equivalent HttpServletRequest methods, 136
Chaining
   MIME, 368, 370-371, 372
   servlet, 355, 365-371, 372
ChangeCase custom tag, 560-564
Character Large Objects (CLOBs), 374
Characters, special
   URL, 816-817
CharArrayWriter, 146, 147
Check boxes, 62
Checksum, 9
Cipher text, 465
/classes directory, 203
class.forName() method, 378, 379
Classloader object, 88
ClassNotFoundException, 378
CLASSPATH, 88
   and getResourceAsStream, 272-273
   items added to, Forte for Java, 248
   JARS added to, 247
   JSSE JAR files added to, 471-472
CLASSPATH libraries, JBuilder, 237
   creating new, 239
   selection dialog box, 238
clearParameters() method, 399
Clients. See also Session management; State management
  

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020