1. Trang chủ
  2. » Công Nghệ Thông Tin

OReilly java servlet programming 2nd edition apr 2001 ISBN 0596000405

1,1K 70 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.086
Dung lượng 6,78 MB

Nội dung

Java Servlet Programming, 2nd Edition > 14 The Tea Framework > 14.1 The Tea Language < BACK CONTINUE > 14.1 The Tea Language Tea is a programming language designed for text formatting It is strongly typed, compiled, and designed to work within a Java-based hosting environment The TeaServlet is that hosting environment, making use of Tea for web page creation and providing a standard hook into servlet engines with which to call Tea template files.[1] [1] Although Tea was designed for text formatting, it's actually possible for a Tea template to control an image-producing application class and easily script together a dynamic image Unlike other content creation tools we'll discuss, Tea templates may output binary data as well as character data The main goal of the Tea language is to enforce separation between content and presentation, without sacrificing basic programming constructs To this end, Tea was created with four basic constraints: Data or datatypes cannot be directly created; they are acquired Acquired data cannot be directly modified in any way A template cannot directly cause harm to its hosting environment Only the minimum amount of programming constructs is provided These constraints additionally protect the system from a buggy or poorly written template, something that's extremely desirable when you have a site accepting new templates by the dozen, as occurs on popular news sites This design also benefits web hosting companies that need to provide clients with the ability to create dynamic pages but don't want any particular client's mistake to negatively impact the rest of the server But do we need another language, especially a language that does less than Java? The Tea Template Language Manual answers this question: Tea resulted from several years of experience with other web page building mechanisms Most web-based applications start out with HTML tags embedded in code, whether it be C, Perl, or Java This approach is adequate for small or first-time projects because it doesn't take very long to develop Because changes to page formatting can occur frequently, and developers don't wish to make these changes, they inevitably evolve into using some kind of token replacement templating mechanism Each token is just a placeholder for a string, which contains application-created data These template systems further evolve into supporting special constructs for formatting tables, forms, and simple conditional logic When introducing programming constructs into a template, the challenge is to come up with something that is powerful enough, yet at the same time be simple and safe If it's too powerful, then complete applications could be developed in templates If it is too weak, then HTML formatting ends up in the application If it isn't simple or safe, then application developers end up writing and maintaining templates Rather than embedding an existing language into something like an ASP or JSP, Tea is a language specially designed to meet the requirements of a templating system It is safe, simple, efficient, and powerful In one instance, Tea is integrated with a special servlet This servlet gives Tea templates control over page building, while retaining strong ties to a backend application written by a Java developer While this servlet provides functionality similar to that of JSPs, Tea enforces correct modelview separation because of the intentional language limitations Although this is also the suggested separation model in JSPs, it cannot be enforced In addition, Tea templates don't support programming features that can be used irresponsibly Modifications need not go through a strict review and testing phase, which would still be required for JSPs Everyone working on a project should be empowered to do their job the most effectively, and Tea does its part by letting you do exactly what you need, as easily as possible, and no more Even on projects run by just developers, using Tea is still beneficial It encourages good development practices and it makes applications easier to maintain Readers of this book should also remember, Tea isn't a language intended for you; it's a language to be used by technical producers It's a simpler language than Java, a safer language than Java, and equally as efficient as Java Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly < BACK CONTINUE > Java Servlet Programming, 2nd Edition Java Servlet Programming, 2nd Edition [Symbol][A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y][Z] Preface Servlet API 2.2 Readers of the First Edition Audience About the Examples Organization Conventions Used in This Book Request for Comments Acknowledgments Acknowledgments from the First Edition Introduction 1.1 History of Web Applications 1.2 Support for Servlets 1.3 The Power of Servlets HTTP Servlet Basics 2.1 HTTP Basics 2.2 The Servlet API 2.3 Page Generation 2.4 Web Applications 2.5 Moving On The Servlet Lifecycle 3.1 The Servlet Alternative 3.2 Servlet Reloading 3.3 Init and Destroy 3.4 Single-Thread Model 3.5 Background Processing 3.6 Load on Startup 3.7 Client-Side Caching 3.8 Server-Side Caching Retrieving Information 4.1 The Servlet 4.2 The Server 4.3 The Client Sending HTML Information 5.1 The Structure of a Response 5.2 Sending a Normal Response 5.3 Using Persistent Connections 5.4 Response Buffering 5.5 Status Codes 5.6 HTTP Headers 5.7 When Things Go Wrong 5.8 Six Ways to Skin a Servlet Cat Sending Multimedia Content 6.1 WAP and WML 6.2 Images 6.3 Compressed Content 6.4 Server Push Session Tracking 7.1 User Authentication 7.2 Hidden Form Fields 7.3 URL Rewriting 7.4 Persistent Cookies 7.5 The Session Tracking API Security 8.1 HTTP Authentication 8.2 Form-Based Authentication 8.3 Custom Authentication 8.4 Digital Certificates 8.5 Secure Sockets Layer (SSL) Database Connectivity 9.1 Relational Databases 9.2 The JDBC API 9.3 Reusing Database Objects 9.4 Transactions 9.5 A Guestbook Servlet 9.6 Advanced JDBC Techniques 9.7 Beyond the Core 10 Applet-Servlet Communication 10.1 Communication Options 10.2 Daytime Server 10.3 Chat Server 11 Servlet Collaboration 11.1 Sharing Information 11.2 Sharing Control 12 Enterprise Servlets and J2EE 12.1 Distributing Load 12.2 Integrating with J2EE 13 Internationalization 13.1 Western European Languages 13.2 Conforming to Local Customs 13.3 Non-Western European Languages 13.4 Multiple Languages 13.5 Dynamic Language Negotiation 13.6 HTML Forms 14 The Tea Framework 14.1 The Tea Language 14.2 Getting Started 14.3 Request Information 14.4 Tea Administration 14.5 Tea Applications 14.6 A Tool Application 14.7 Final Words 15 WebMacro 15.1 The WebMacro Framework 15.2 Installing WebMacro 15.3 WebMacro Directives 15.4 WebMacro Templates 15.5 A Tool Application 15.6 Filters 16 Element Construction Set 16.1 Page Components as Objects 16.2 Displaying a Result Set 17 XMLC 17.1 A Simple XML Compile 17.2 The Manipulation Class 17.3 A Tool Application 18 JavaServer Pages 18.1 Using JavaServer Pages 18.2 Behind the Scenes 18.3 Expressions and Declarations 18.4 Directives 18.5 JSP and JavaBeans 18.6 Includes and Forwards 18.7 A Tool Application 18.8 Custom Tag Libraries 19 Odds and Ends 19.1 Parsing Parameters 19.2 Sending Email 19.3 Using Regular Expressions 19.4 Executing Programs 19.5 Using Native Methods 19.6 Acting as an RMI Client 19.7 Debugging 19.8 Performance Tuning 20 What's New in the Servlet 2.3 API 20.1 Changes in the Servlet API 2.3 20.2 Conclusion A Servlet API Quick Reference GenericServlet RequestDispatcher Servlet ServletConfig ServletContext ServletException ServletInputStream ServletOutputStream ServletRequest ServletResponse SingleThreadModel UnavailableException B HTTP Servlet API Quick Reference Cookie HttpServlet HttpServletRequest HttpServletResponse HttpSession HttpSessionBindingEvent HttpSessionBindingListener HttpSessionContext HttpUtils C Deployment Descriptor DTD Reference D HTTP Status Codes E Character Entities F Charsets Colophon Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly © 2001, O'Reilly & Associates, Inc Java Servlet Programming, 2nd Edition > 14 The Tea Framework < BACK CONTINUE > Chapter 14 The Tea Framework Now we're ready to discuss servlet-based content creation frameworks We'll postpone our discussion of JSP because it's the most complicated content creation alternative and start instead with a look at Tea TeaServlet (colloquially known as Tea) is a product from the Walt Disney Internet Group (WDIG)formerly GO.comdeveloped internally over the years to aid in the creation of high-traffic web sites such as ESPN.com, NFL.com, Disney.com, DisneyLand.com, Movies.com, ABC.com, and GO.com It was recently released as open source in the hopes that others would find Tea useful and continue to enhance the tool The strategy makes business sense; you share your tools in the hope that others will help sharpen them Here we discuss TeaServlet 1.1.0, available at http://opensource.go.com It requires Servlet API 2.1 or 2.2 and JDK 1.2 or later TeaServlet's license is Apache-style, one of the leastrestrictive licenses and most appealing to developers because it means you can use Tea in creating new products and sites without releasing those products as open source This is the license model used by all Apache projects, including the Apache web server and the Tomcat server Tea was designed for projects run by small teams of developers and technical producers The developer's role is the creation of "applications" written in Java and installed into the TeaServlet A producer creates and maintains the final appearance of dynamic web pages by writing Tea templates that call upon functions provided by the developer's applications For example, on an ESPN web site, one developer creates an application for team statistics, one developer (working independently) creates an application for player statistics, and a technical producer posts the data to the web using Tea templates In fact, several producers working independently can use the same backend data to create targeted sites for different audiencessomething WDIG has done for their sites including Disney.com, Movies.com, ESPN.com, and GO.com The templates are written in the Tea language to enforce an excellent separation of content from presentation Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly < BACK CONTINUE > \u00D0 Ð Ð \u00D1 Ñ Ñ \u00D2 Ò \u00D3 Icelandic S Ñ Capital N, tilde S Ò Ị Capital O, grave accent S Ó Ó Ĩ Capital O, acute accent S \u00D4 Ô Ô Ô Capital O, S circumflex accent \u00D5 Õ Õ Õ Capital O, tilde \u00D6 Ö Ö Ö Capital O, umlaut S \u00D7 × × x Multiply sign P \u00D8 Ø Ø Ø Capital O, slash S \u00D9 Ù Ù Ù Capital U, grave accent S \u00DA Ú Ú Ú Capital U, acute accent S S \u00DB Û Û Û Capital U, S circumflex accent \u00DC Ü Ü Ü Capital U, umlaut S \u00DD Ý Ý Capital Y, acute accent S \u00DE Þ Þ Capital thorn, Icelandic S \u00DF ß ß ß Small sz ligature, S German \u00E0 à à Small a, grave accent S \u00E1 á á Small a, acute accent S \u00E2 â â â Small a, S circumflex accent \u00E3 ã ã ã Small a, tilde S \u00E4 ä ä ä Small a, umlaut S \u00E5 å å å Small a, ring S \u00E6 æ æ ổ Small ae ligature S \u00E7 ç ç ỗ Small c, cedilla S \u00E8 è è è Small e, grave accent S \u00E9 é é é Small e, acute accent S \u00EA ê ê ê Small e, S circumflex accent \u00EB ë ë ë Small e, umlaut S \u00EC ì ì ì Small i, grave accent S \u00ED í í í Small i, acute accent S \u00EE î î ỵ Small i, S circumflex accent \u00EF ï ï ï Small i, umlaut S \u00F0 ð ð Small eth, Icelandic S \u00F1 ñ ñ đ Small n, tilde S \u00F2 ò ò ò Small o, grave accent S \u00F3 ó ó ó Small o, acute accent S \u00F4 ô ô ô Small o, S circumflex accent \u00F5 õ õ õ Small o, tilde S \u00F6 ö ö ö Small o, umlaut S \u00F7 ÷ ÷ ÷ Division sign P \u00F8 ø ø ø Small o, slash S \u00F9 ù ù ù Small u, grave accent S \u00FA ú ú ú Small u, acute accent S \u00FB û û û Small u, S circumflex accent Small u, umlaut S ý Small y, acute accent S þ þ Small thorn, Icelandic S ÿ ÿ Small y, umlaut S \u00FC ü ü \u00FD ý \u00FE \u00FF ü ÿ Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly < BACK CONTINUE > Java Servlet Programming, 2nd Edition > F Charsets < BACK CONTINUE > Appendix F Charsets The following table lists the suggested charset(s) for a number of languages Charsets are used by servlets that generate multilingual output; they determine which character encoding a servlet's PrintWriter is to use By default, the PrintWriter uses the ISO-8859-1 (Latin-1) charset, appropriate for most Western European languages To specify an alternate charset, the charset value must be passed to the setContentType( ) method before the servlet retrieves its PrintWriter, for example: res.setContentType("text/html; charset=Shift_JIS"); // A Japanese charset PrintWriter out = res.getWriter(); // Writes Shift_JIS Japanese The charset can also be set implicitly using the setLocale( ) method, for example: res.setContentType("text/html"); res.setLocale(new Locale("ja", "")); // Sets charset to Shift_JIS PrintWriter out = res.getWriter(); // Writes Shift_JIS Japanese The setLocale( ) method assigns a charset to the response according to the table listed here Where multiple charsets are possible, the first listed charset is chosen Note that not all web browsers support all charsets or have the fonts available to represent all characters, although at minimum all clients support ISO-8859-1 Further note that the UTF-8 charset can represent all Unicode characters and may be assumed a viable alternative for all languages Language Code Language Suggested Charsets Albanian sq ISO-8859-2 Arabic ar ISO-8859-6 Bulgarian bg ISO-8859-5 Byelorussian be ISO-8859-5 Catalan (Spanish) ca ISO-8859-1 Chinese (Simplified/Mainland) zh GB2312 Chinese (Traditional/Taiwan) zh (country TW) Big5 Croatian hr ISO-8859-2 Czech cs ISO-8859-2 Danish da ISO-8859-1 Dutch nl ISO-8859-1 English en ISO-8859-1 Estonian et ISO-8859-1 Finnish fi ISO-8859-1 French fr ISO-8859-1 German de ISO-8859-1 Greek el ISO-8859-7 Hebrew he (formerly iw) ISO-8859-8 Hungarian hu ISO-8859-2 Icelandic is ISO-8859-1 Italian it ISO-8859-1 Japanese ja Shift_JIS, ISO-2022-JP, EUCJP[A] Korean ko EUC-KR[B] Latvian, Lettish lv ISO-8859-2 Lithuanian lt ISO-8859-2 Macedonian mk ISO-8859-5 Norwegian no ISO-8859-1 Polish pl ISO-8859-2 Portuguese pt ISO-8859-1 Romanian ro ISO-8859-2 Russian ru ISO-8859-5, KOI8-R Serbian sr ISO-8859-5, KOI8-R Serbo-Croatian sh ISO-8859-5, ISO-8859-2, KOI8R Slovak sk ISO-8859-2 Slovenian sl ISO-8859-2 Spanish es ISO-8859-1 Swedish sv ISO-8859-1 Turkish tr ISO-8859-9 Ukranian uk ISO-8859-5, KOI8-R [A] First supported in JDK 1.1.6 Earlier versions of the JDK know the EUC-JP character set by the name EUCJIS, so for portability you can set the character set to EUC-JP and manually construct an EUCJIS PrintWriter [B] First supported in JDK 1.1.6 Earlier versions of the JDK know the EUC-KR character set by the name KSC_5601, so for portability you can set the character set to EUC-KR and manually construct a KSC_5601 PrintWriter Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly < BACK CONTINUE > Java Servlet Programming, 2nd Edition > Colophon < BACK Colophon Our look is the result of reader comments, our own experimentation, and feedback from distribution channels Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects The animal on the cover of Java Servlet Programming, Second Edition is a common European bear There are eight species of bear: giant panda, spectacled, sun, sloth, Asiatic black, American black, brown, and polar Nearly all bears, except a few populations of spectacled and sun bears, live in the northern hemisphere All bear species have a similar anatomy, but they vary greatly in size, from the sun bearthe smallest, weighing 150 pounds or lessto the polar bear, which can grow to up to 1,800 pounds The habitats in which they live vary as well, as does their diet Bears are carnivores, but all species except the polar bear have an omnivorous diet Biologically speaking, it is thought that bears may be related more closely to walruses and sea lions than to other carnivores Their life span is not well known, but it is thought to be about 25 to 40 years; bears in captivity tend to live longer than those in the wild Colleen Gorman was the production editor, and Norma Emory was the copyeditor for Java Servlet Programming, Second Edition Catherine Morris and Leanne Soylemez provided quality control Frameworks Consulting provided production support Ellen Troutman-Zaig wrote the index Hanna Dyer designed the cover of this book, based on a series design by Edie Freedman The cover image is a 19th-century engraving from the Dover Pictorial Archive Emma Colby produced the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font David Futato designed the interior layout based on a series design by Nancy Priest Judy Hoer converted the Microsoft Word files to FrameMaker 5.5.6, using tools created by Mike Sierra The heading font is Bodoni BT, the text font is New Baskerville, and the code font is Constant Willison The illustrations that appear in the book were produced by Robert Romano using Macromedia FreeHand 8 and Adobe Photoshop 5 This colophon was written by Leanne Soylemez Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly < BACK © 2001, O'Reilly & Associates, Inc Java Servlet Programming, 2nd Edition Java Servlet Programming, 2nd Edition Copyright © 2001, 1998 O'Reilly & Associates, Inc All rights reserved Printed in the United States of America Published by O'Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472 Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks and The Java Series is a trademark of O'Reilly & Associates, Inc Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O'Reilly & Associates, Inc was aware of a trademark claim, the designations have been printed in caps or initial caps Some of the material in Chapter 2 was first published in JavaWorld magazine, December 1999, ITworld.com, Inc The association between the image of a common European bear and Java servlet programming is a trademark of O'Reilly & Associates, Inc While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly © 2001, O'Reilly & Associates, Inc ... Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly © 2001, O'Reilly & Associates, Inc Java Servlet Programming, 2nd Edition Java Servlet Programming, 2nd Edition [Symbol][A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U]... Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly < BACK CONTINUE > Java Servlet Programming, 2nd Edition Java Servlet Programming, 2nd Edition Jason Hunter William Crawford... Authorization header , 2nd autocommit mode Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly © 2001, O'Reilly & Associates, Inc Java Servlet Programming, 2nd Edition Java Servlet Programming, 2nd Edition

Ngày đăng: 26/03/2019, 16:30

TỪ KHÓA LIÊN QUAN