Example: barber

JSP: The Complete Reference - Yola

JSP: The Complete ReferenceAbout the Hanna has more than 20 years experienceas a programmer, systems architect, analyst, andproject manager. He has developed network-basedsoftware at IBM, and served as a consultant toChase Manhattan Bank. He is the author ofInstant Java Servlets,and works as a softwaredeveloper for SAS 2001 The McGraw-Hill Companies, Inc. Click Here for Terms of : The CompleteReferencePhil HannaOsborne/McGraw-HillNew York Chicago San FranciscoLisbon London Madrid Mexico CityMilan New Delhi San JuanSeoul Singapore Sydney TorontoCopyright 2001 by The McGraw-Hill Companies. All rights reserved. Manufactured in the United States of America. Except as per-mitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or byany means, or stored in a database or retrieval system, without the prior written permission of the publisher.

JSP: The Complete Reference Phil Hanna Osborne/McGraw-Hill New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto

Tags:

  Reference, Complete, The complete reference

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of JSP: The Complete Reference - Yola

1 JSP: The Complete ReferenceAbout the Hanna has more than 20 years experienceas a programmer, systems architect, analyst, andproject manager. He has developed network-basedsoftware at IBM, and served as a consultant toChase Manhattan Bank. He is the author ofInstant Java Servlets,and works as a softwaredeveloper for SAS 2001 The McGraw-Hill Companies, Inc. Click Here for Terms of : The CompleteReferencePhil HannaOsborne/McGraw-HillNew York Chicago San FranciscoLisbon London Madrid Mexico CityMilan New Delhi San JuanSeoul Singapore Sydney TorontoCopyright 2001 by The McGraw-Hill Companies. All rights reserved. Manufactured in the United States of America. Except as per-mitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or byany means, or stored in a database or retrieval system, without the prior written permission of the publisher.

2 0-07-219431-6 The material in this eBook also appears in the print version of this title: 0-07-212768-6. All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trade-marked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringe-ment of the trademark. Where such designations appear in this book, they have been printed with initial caps. McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporatetraining programs. For more information, please contact George Hoare, Special Sales, at or (212)904-4069. TERMS OF USEThis is a copyrighted work and The McGraw-Hill Companies, Inc. ( McGraw-Hill ) and its licensors reserve all rights in and to thework.

3 Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store andretrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative worksbased upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill s prior con-sent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Yourright to use the work may be terminated if you fail to comply with these terms. THE WORK IS PROVIDED AS IS . McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIESAS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THEWORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OROTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITEDTO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

4 McGraw-Hill and itslicensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation willbe uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, erroror omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the con-tent of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for anyindirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, evenif any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause what-soever whether such claim or cause arises in contract, tort or : MaryThis page intentionally left at a GlancePart IThe Web Programming Environment1 The Web Marketplace.

5 32 Evolution of the Web Application ..53 Overview of the Hypertext Transfer Protocol (HTTP) ..114 Introduction to Servlets ..235 JSP Overview ..53 Part IIElements of JSP6 JSP Syntax and Semantics ..637 Expressions and Scriptlets ..898 Declarations ..1119 Request Dispatching ..13310 The Page Directive ..16111 JSP Tag Extensions ..183viiCopyright 2001 The McGraw-Hill Companies, Inc. Click Here for Terms of IIIJSP in Action12 HTML Forms ..26113 Database Access ..29114 Session and Thread Management ..35315 JSP and JavaBeans ..41516 JSP and XML ..45117 JSP Testing and Debugging ..49318 Deploying Web Applications ..52919 Case Study: A Product Support Center ..551 Part IVJSP and Other Web Components20 Communicating with Other Clients ..67921 Communicating with Other Servers ..703 Part VAppendixesAServlet API Version.

6 723 BJSP API Version ..793 CHTTP Reference ..833 Index ..845viiiJSP: The Complete ReferenceContentsPreface..xixAcknowledgm ents..xxvPart IThe Web Programming Environment1 The Web Marketplace ..32 Evolution of the Web Application ..5 Birth of the Web ..6 Growth of the Web Programming Model ..6 The Shift from Client-Side to Server-Side Solutions ..93 Overview of the Hypertext Transfer Protocol (HTTP) ..11 What Is HTTP? ..12A Language for Requesting Documents overthe Internet ..12 The HTTP Specification ..12ixCopyright 2001 The McGraw-Hill Companies, Inc. Click Here for Terms of : The Complete ReferenceHTTP Request Model ..13 Connecting to the Web Server ..14 Sending the HTTP Request ..15 Server Acceptance of the Request ..16 The HTTP Response from the Server ..16 Examples ..17 Summary ..214 Introduction to Servlets.

7 23 Servlet Lifecycle ..24init ..25service ..26destroy ..27 Example: Kilometers per Liter to Miles per Gallon Servlet ..27 Servlet Classes ..31 Servlet ..32 Servlet Request ..36 Servlet Response ..41 Servlet Context ..44 Threading Models ..47 SingleThreadModel ..49 HTTP Sessions ..49 The HttpSession Interface ..50 Summary ..525 JSP Overview ..53 How JSP Works ..54A Basic Example ..56 Part IIElements of JSP6 JSP Syntax and Semantics ..63 The JSP Development Model ..64 Components of a JSP Page ..65 Directives ..65 Comments ..68 Expressions ..69 Scriptlets ..70 Declarations ..71 ContentsxiImplicit Objects ..74 Standard Actions ..75 Tag Extensions ..78A Complete Example ..78A Page Directive ..83A <jsp:include> Action ..83 Scriptlet ..84 JSP Expressions ..85A Declaration..86 Summary.

8 877 Expressions and Scriptlets ..89 Expressions ..90 Scriptlets ..91 Expression and Scriptlet Handling by the JSP Container ..93 HTML Template Data and Expressions ..94 Scriptlet Contents ..94 Container-Generated Initialization and Exit Code ..96 Implicit Objects and the JSP Environment ..97 Request ..98 Response ..99 PageContext ..100 Session ..102 Application ..103 Out ..104 Config ..106 Page ..106 Exception ..106 Initialization Parameters ..107 Summary ..1098 Declarations ..111 What Is a Declaration? ..112 Where Declaration Code Is Generated ..112 Primary Uses for Declarations ..117 Variable Declarations ..117 Thread Safety and Instance Variables ..118 Method Definitions ..122 Overriding jspInit and jspDestroy ..126 Access to Implicit Objects ..128 Inner Classes ..1289 Request Dispatching.

9 133 Anatomy of Request Processing ..134 Including Other Resources ..136 The include Directive ..136 How It Works ..137 Effect of Changes in an Included File ..138 Using the include Directive to Copy Source Code ..139 The <jsp:include> Action ..140 How It Works ..141 Which Method to Use ..153 Forwarding Requests ..154 The RequestDispatcher Object ..158 Request Dispatching vs. Redirection ..159 Model 1 vs. Model 2 ..159 Summary ..16010 The Page Directive ..161language ..162extends ..164 Required Interfaces for a JSP Superclass ..164A JSP Superclass Example ..166import ..170session ..172buffer and autoFlush ..172isThreadSafe ..173info ..174contentType ..174errorPage and isErrorPage ..176 Summary ..18111 JSP Tag Extensions ..183 Why Custom Tags? ..184 Developing Your First Custom Tag.

10 186 Step 1 Define the Tag ..186 Step 2 Create the TLD Entry ..187 Step 3 Write the Tag Handler ..188 Step 4 Incorporate the Tag into a JSP Page ..192 How Tag Handlers Work ..194 What the JSP Container Does ..194 What a Tag Handler Does ..196 Tag Libraries ..197 The Tag Library Descriptor (TLD) ..197 The taglib Directive ..199xiiJSP: The Complete ReferenceThe Tag Handler API ..200 The Tag Interface ..200 The TagSupport Class ..202 The Tag Handler Life Cycle ..202 The Flowchart ..204An Example of Generated Code ..206 Defining Tag Attributes ..212 The Body Tag Handler API ..219 BodyContent ..219 The BodyTag Interface ..221 The BodyTagSupport Class ..222 The Body Tag Handler Life Cycle ..223 The Flowchart ..223 Defining Scripting Variables ..226 The TagExtraInfo Class ..227 Validating Tag Attributes.


Related search queries