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

OReilly java servlet programming 2nd edition apr 2001 ISBN 0596000405

1,1K 73 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

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

This servlet givesTea templates control over page building, while retaining strong ties to abackend application written by a Java developer.. Java Servlet Programming, 2nd Edition, © 200

Trang 1

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

Trang 2

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 todevelop

Because changes to page formatting can occur frequently, and developersdon't wish to make these changes, they inevitably evolve into using somekind of token replacement templating mechanism Each token is just aplaceholder for a string, which contains application-created data Thesetemplate systems further evolve into supporting special constructs forformatting tables, forms, and simple conditional logic

Rather than embedding an existing language into something like an ASP orJSP, Tea is a language specially designed to meet the requirements of atemplating system It is safe, simple, efficient, and powerful

In one instance, Tea is integrated with a special servlet This servlet givesTea templates control over page building, while retaining strong ties to abackend application written by a Java developer While this servlet

view separation because of the intentional language limitations Althoughthis is also the suggested separation model in JSPs, it cannot be enforced

provides functionality similar to that of JSPs, Tea enforces correct model-In addition, Tea templates don't support programming features that can beused irresponsibly Modifications need not go through a strict review andtesting phase, which would still be required for JSPs

Everyone working on a project should be empowered to do their job themost effectively, and Tea does its part by letting you do exactly what youneed, as easily as possible, and no more Even on projects run by just

developers, using Tea is still beneficial It encourages good developmentpractices and it makes applications easier to maintain

Trang 3

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

Trang 9

Java Servlet Programming, 2nd Edition > 14 The Tea Framework

Trang 10

Now we're ready to discuss servlet-based content creation frameworks We'llpostpone 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 yourtools in the hope that others will help sharpen them Here we discuss TeaServlet1.1.0, available at http://opensource.go.com It requires Servlet API 2.1 or 2.2and JDK 1.2 or later TeaServlet's license is Apache-style, one of the least-restrictive licenses and most appealing to developers because it means you canuse Tea in creating new products and sites without releasing those products asopen source This is the license model used by all Apache projects, includingthe 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 finalappearance of dynamic web pages by writing Tea templates that call upon

functions provided by the developer's applications For example, on an ESPNweb 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, severalproducers working independently can use the same backend data to create

targeted sites for different audiencessomething WDIG has done for their sitesincluding Disney.com, Movies.com, ESPN.com, and GO.com The templatesare written in the Tea language to enforce an excellent separation of contentfrom presentation

Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 11

14.2 Getting Started

To get familiar with Tea, let's start simple by looking at a few standalone templates.These templates aren't going to take advantage of any supporting "application" Javaclasses and thus won't be able to do very much Here is our first template:

<% template SimplePage() %>

This is a simple page that does nothing special.

This template simply outputs "This is a simple page that does nothing special." toeveryone who accesses it Templates are composed of code and text regions Coderegions are delimited by <% and %> (no other special delimiters are required) Textoutside a code region is output by the template as is, which is why this templateprints the simple statement

TeaServlet under the name tea with an init parameter specifying a location forconfiguration information Also set up a prefix mapping rule that /tea/* invokesthe tea servlet An example web.xml addition is shown in Example 14-1

Trang 12

of the TeaServlet It can be quite long, which is why the web.xml file points to an

Trang 13

Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 14

Second Edition April 2001 ISBN: 0-596-00040-5, 780 pages

The second edition of this popular book has beencompletely updated to add the new features of the JavaServlet API Version 2.2, and new chapters on servletsecurity and advanced communication In addition tocompletely covering the 2.2 specification, we have includedbonus material on the new 2.3 version of the specification

Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 15

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]

Trang 23

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]

Trang 27

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]

Trang 40

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]

Trang 47

dynamic content

Trang 49

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]

Trang 58

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]

Trang 62

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]

Trang 70

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]

Trang 77

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]

Trang 83

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]

Trang 89

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]

Trang 91

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]

Trang 95

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]

Trang 99

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]

Trang 102

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]

Trang 105

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]

Trang 113

PUT method , 2nd

Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 114

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]

Trang 115

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]

Trang 120

applet/servlet communication

Trang 122

Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 123

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]

Trang 125

classes and methods, routine servlet development extensibility of

Trang 129

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]

Trang 136

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]

Trang 141

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]

Trang 143

Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 144

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]

Trang 149

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]

Trang 151

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]

Y

Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 152

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]

Trang 153

Java Servlet Programming, 2nd Edition > Preface

Trang 154

Since I wrote the first edition of this book, servlets and the server-side Javaplatform have grown in popularity beyond everyone's wildest expectations.Adoption is pervasive Web server vendors now offer servlet support as a

standard feature The Java 2, Enterprise Edition (J2EE), specification has

included servlets as a core component, and application server vendors wouldn't

be caught dead without a scalable servlet implementation It's more than justvendor-driven hype too Servlets have become the basis for JavaServer Pages(JSP) and other frameworks, and servlet technology now supports such high-traffic sites as ESPN.com and AltaVista.com

Not surprisingly, the servlet landscape looks somewhat different today than itdid when the first edition went to print The Servlet API has undergone tworevisions, with a third revision on the way The familiar startup companies LiveSoftware and New Atlanta that once made money selling the JRun and

ServletExec servlet engines (now called servlet containers) have gotten

themselves noticed and were purchased by larger web-focused companies,

Allaire and Unify, respectively They now offer features above and beyond basicservlet support in an effort to differentiate themselves

Amazingly, the official javax.servlet and javax.servlet.http packages havebeen the first Java classes to be officially released as open source They weretransferred to the Apache Software Foundation (ASF) and now reside at

specification, but bug fixes and specification updates can now be handled by aset of trusted open source developersincluding yours truly, who recently had thechance to fix a bug to improve conditional GET request handling in

HttpServlet In addition, the server that acts as the Servlet API reference

implementation was also transferred to the ASF and made available as opensource under the name Apache Tomcat Tomcat has since become one of themost popular servlet containers For more information, see

The servlet world has changed, and this book brings you up-to-date It explainseverything you need to know about Java servlet programming, from start tofinish The first five chapters cover the basics: what servlets are, what they do,

Trang 155

Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 156

Response output buffering has been added

Control over HTTP headers has been enhanced

More advanced error handling can now be used

The API has been "cleaned up" to make method names more consistentand predictable

The Servlet API is now defined by a formal specification document, withfuture API updates managed by the formal Java Specification Request(JSR) process

Trang 157

All these changes, and many other more minor changes, are fully explained inthis new edition This second edition also has extensive coverage of the mostexciting area of servlet development: techniques for building on the servlet base

to easily and efficiently create dynamic content for real-world sites In this

based content creation technologies:

edition you'll find tutorials on five of the most popular open source servlet-JavaServer Pages (JSP), the Sun standard, developed and released in

conjunction with servlets

Tea, created by the Walt Disney Internet Group (formerly GO.com), usedfor high-traffic sites like ESPN.com, NFL.com, Disney.com,

DisneyLand.com, GO.com, and Movies.com

WebMacro, created by Semiotek and used by the search engine AltaVista

XMLC, created by Lutris Technologies to leverage the power of XMLtechnology for the Web, used by innovative sites like customatix.com

The Element Construction Set (ECS), created by Apache to handle themost demanding programming needs

This second edition also introduces WAP, the Wireless Application Protocol,and explains how to create servlet-based web applications for wireless devices

Servlet API 2.3

At the time of the writing, Servlet API 2.3 is under development However, ithas not yet been finalized Consequently, the text in this edition includes invarious places a brief mention of the changes expected in the Servlet API 2.3 Inaddition, the final chapter of this book takes a thorough look at the October

2000 draft specification of the Servlet API 2.3, which should help you becomefamiliar with the latest features that the Servlet API 2.3 will offer We shouldpoint out, however, that these specifications are still subject to change, and thereleased version may differ slightly from the material presented here

Trang 158

< BACK CONTINUE >

Trang 159

servlets integrate into the J2EE platform

Due to the significant impact the pluggable web applicationmodel has made

across all aspects of servlet programming, we recommend readers of the firstedition read each chapter of interest and take note of the new mechanisms thatexist for accomplishing the traditional tasks For readers whose time is limited,

we include for your convenience a list of the most significant changes in

Last updated on 3/20/2003 Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

Trang 160

Audience

Is this book for you? It is if you're interested in developing applications to bedeployed on the Web Specifically, this book was written to help:

J2EE programmers

Servlets are an integral part of the Java 2, Enterprise Edition, standard.Programmers developing for J2EE servers can learn how best to integrateservlets into other backend technologies

JSP programmers

JavaServer Pages (JSP) are built on top of servlets To take full advantage

of JSP requires an understanding of servlets, which this book provides.This book also includes a tutorial on JSP as well as the four leading

alternatives to JSP

Java applet programmers

It has always been difficult for an applet to talk to a server Servlets make iteasier by giving the applet an easy-to-connect-to, Java-based agent on theserver

CGI programmers

CGI is a popular method of extending the functionality of a web server.Servlets provide an elegant, efficient alternative

Other server-side programmers

There are many CGI alternatives including FastCGI, PHP, NSAPI, WAI,ISAPI, ASP, and now ASP+ Each of these has limitations regarding

portability, security, performance, and/or integration with backend datasources Servlets tend to excel in each of these areas

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

TỪ KHÓA LIÊN QUAN