JSP+XML的技术纲要

(来源:http://java.sun.com)

Sun Microsystems ( http://java.sun.com/jsp )
作者:Eduardo Pelegri-Llopart (pelegri@eng.sun.com)

( Blueski.class编译 )

本文提纲:
* JSP, Servlets & J2EE
* JSP & XML
* 现状
(附:原文)


1 JSP, Servlets & J2EE


1.1 J2EE平台

* 具有明确的规范
* 经过了各种 兼容性测试
* 具有很多的 实施参考 (RI)
* 丰富的功能体现在以下方面:
– JSP/Servlets
– JDBC
– EJB
– JMS
– Connector to EIS (J2EE 1.3)
* 具有非常实用的价值


1.2 J2EE所在的Web层


(请参考下图:)




 


1.3 JSP/Servlets扮演的角色
(译者注:我把JSP和Servelet混在一起了,你可参考本文所附的原文)

* application的入口
* 和外界交互
* 一般都采用HTTP协议
* 客户端可能是以下几种类型:
- Browser
- Applet
- Desktop application (Java Web Start)
- 无线设备
- Server application (B2B)

1.4 JSP/Servlets的用途
* 可以用于
– JSP & Servlet Container
– J2EE Container
* Common mindshare
* Best-of-breed implementation
* 已经获得 广泛的支持
* 动态内容生成
* 具有 简单化的构架
* 由container管理
* 经常 使用JavaBeans和Tag Lib

 

1.5 一个例子


<?xml version="1.0">
<%@ page contentType=”text/xml” %>
<%@ taglib prefix="x" uri="..." %>
<wml>
<card id="card1" title="Flowers">
<p>
Flowers available:
<br/>
<x:enumerate inventory="flowers"
id="aFlower">
<%= aFlower.type %>
<br/>
</x:iterate>
<br/>
</p>
</card>
</wml>

1.6 Tag Lib


* 抽象提炼
* XML语法
* Run-Time协议
– 集成到JSP页面中去
– 容易组合和定制
– 由JSP container管理
– 简单的协议,用于简单的需求

1.7 各种协同工作的角色


* 站点页面作者
– 从数据开发者提供的数据中建立表达presentation
– 用户界面方面的专家
– 使用Tag Lib和JavaBeans
– 使用页面工具
* 开发者
– 为页面作者提供数据存取
– 服务器端组织的专家
– 定义Tag Lib和JavaBeans
– IDE

2 JSP & XML


2.1 XML在JSP技术中的应用


JSP页面可以:
– 使用XML
– 生成XML
– 改变XML
* 将JSP页面作为XML文档
* XML配置

2.2 使用XML


* 将XML解析到对象(由开发者完成)
– 硬编码
– 使用Adelard技术
* 解析和复述抽象
* 转变以后插入– XSLT

2.3 解析成为对象


<%@ taglib uri="..." prefix="tl" %>
<html>
<tl:parse id="saleBooks" type="BookInventory"
xml="Book_Inventory_URL"/>
<head>...
<body>
<table border="0" width="50%">
<tl:iterate
id ="bk" type="Book"
collection="<%= saleBooks.getBooks()%>" >
<tr>
<td><jsp:getProperty name="bk" property="title"/></td>
</tr>
</tl:iterate>
</table>
</body>
</html>



2.4 解析和复述


<%@ taglib uri="..." prefix="tl" %>
<html>
<head>...
<body>
<table border="0" width="50%">
<tl:iterateOnXMLStream
id="bk" type="Book"
xml="Book_Inventory_URL">
<tr>
<td><jsp:getProperty name="bk" property="title"/></td>
</tr>
</tl:iterateOnXMLStream>
</table>
</body>
</html>



2.5 组合Data

(请参考下图:)







2.6 转化后插入

 


<%@taglib uri="http://jakarta.apache.org/taglibs/xsl/1.0"
prefix="x" %>
<html>
<head>...
<body>
<center> Welcome
<x:apply xml="Customer_URL" xsl="store.xsl"/>!
<p>
On Sale Today ...
<p>
<x:apply xml="Inventory_URL" xsl="store.xsl"/>
</center>
</body>
</html>

2.7 制作XML


* 客户端可以是
– Gateway网关
– 设备(WAP, XHTML)
* XML
* XML + StyleSheet样式表

2.8 VoiceXML 和 WAP Gateway网关

(请参考下图:)





2.9 生成 XML

(请参考下图:)



2.10 XSLT on XML

(请参考下图:)



2.11 JSP和XSLT


* JSP强化了:
– Template & Java
– Multiple Sources
– Open-ended Portable Abstraction
* XSLT强化了:
– 循环的tree transformation
– 有良好定义的输入输出
* XPath



2.12 生成内容用于


Multiple Devices
* One back end source
* 许多客户
* 将总的维护费用最小化
* 达到预期的性能



2.13 多客户的XSLT样式

(请参考下图:)



2.14 多客户的短管道 Short Pipelines

(请参考下图:)


2.15 多客户的组合途径

(请参考下图:)



2.16 在JSP技术中使用XML


* JSPs Pages
将JSP页面作为 XML文档

 * Manipulation
 – Apply XSLT to generate JSP
 * Authoring
 – JSP pages from XML objects
 * Validation
 – TagLibraryValidator
 * Standarized in JSP 1.2

* XML配置

 * Tag Library Descriptor
 * Servlet configuration
 – Resources
 – Mappings
 – Filters (JSP 1.2)
 – 其它



3 现状

3.1 业界支持

容器方面:
Apache,Allaire,ATG Dynamo,BEA Weblogic,Bluestone,Caucho,Gemstone,IBM’s WebSphere
Inprise AppServer,Iplanet iWS, iAS, Oracle,Persistence, Unify

一些用户:
PeopleSoft,I2,CP ...

一些站点:
Delta.com, Food.com, CarOrder.com ...

工具
MacroMedia UltraDev,Adobe GoLive,Unify eWeb Studio,WebGain’s Studio
Forte for Java,Oracle Jdeveloper,Inprise Jbuilder,ATG Dynamo, ...

3.2 新的JSP & Servlets技术


* JSR-053
* Servlet 2.3
– Filters
– Application Events
* JSP 1.2
– JSP页面的XML方式查询
– 许多改进和增强
*  Apache组织的推行
– jakarta.apache.org/tomcat

3.3 JSP Tag Library


* JSR-052
* 标准的JSP tag library
– 丰富的功能
– XSLT
– XPATH
– 其它的XML的进程
– Apache组织的推进( jakarta.apache.org/taglibs)


3.4 框架的支持


* J2EE体系
* JSP/Servlet体系
– Struts
– Apache组织的推进(jakarta.apache.org/struts)

3.5 JSP工具支持


* 大多数情况下是为页面作者提供的
– 有一些是为TagLib工作者提供
* 已经存在于一些工具中
– 例如,UltraDev支持Struts
* 近6个月的预测
– 标准的taglib将出现,还有各种其他的taglib

3.6 XML解析和转化


* JAXP 1.1
– 下一代 J2SE(JDK)的组成部分
– DOM level 2
– XSLT
– 和TRaX (XSLT激活)进行组合
– Apache组织的推进
* XSLTC
– XSLT编译器
– 更快,更小的脚本

3.7 数据绑定


Beans Long Term Persistance
* Adelard
– 下一代J2SE的组成部分
– 数据绑定
* JavaBeans Long Term Persistance
– 下一代 J2SE的组成部分
– 图形化Swing机制

3.8 XML Messaging


* XML messaging
– JMS
– ebXML
– JAXM
– Message Beans (J2EE 1.3)

(剧终)

*******************************

为防误译,特附原来文档,这是sun站点的官方pdf文档,有685K,我特地从中裁剪出来的。:)

JSP Technology and XML技术纲要
Eduardo Pelegri-Llopart
Sun Microsystems
pelegri@eng.sun.com
http://java.sun.com/jsp

提纲
* JSP, Servlets & J2EE
* JSP and XML
* Status

1 JSP, Servlets & J2EE
1。1 J2EE Platform

* Specification
* Compatibility Tests
* Reference Implementation (RI)
* Rich Functionality
– JSP and Servlets
– JDBC
– EJB
– JMS
– Connector to EIS (J2EE 1.3)

1。2 J2EE Benefits

* Common Mindshare
– Documentation
– Training
– Tool Support
* Portability

* Best-of-Breed Implementations

1。3 Web Layer of J2EE
(插图1)

1.4 Role of JSP and Servlets
* Entry point to application
* Interacts with the exterior
* Usually through HTTP
* Client may be:
* Browser
* Applet
* Desktop application (Java Web Start)
* Wireless Device
* Server application (B2B)

1.5 JSP and Servlets
* Can be used in
– JSP & Servlet Container
– J2EE Container
* Common mindshare
* Best-of-breed implementation
* Wide support

1.6 What Is a Servlet?
* Extension mechanism
* Dynamic content generation
* Mapped to URLs
* Simple architecture
* Managed by container

1.7 JSP Page
* A textual document
* Describes a request – response map
* Servlet Semantics

1.8 一个例子
<?xml version="1.0">
<%@ page contentType=”text/xml” %>
<%@ taglib prefix="x" uri="..." %>
<wml>
<card id="card1" title="Flowers">
<p>
Flowers available:
<br/>
<x:enumerate inventory="flowers"
id="aFlower">
<%= aFlower.type %>
<br/>
</x:iterate>
<br/>
</p>
</card>
</wml>

1.9 JSP Page
* A textual document
* Builds on
– Template data
– Dynamic content
* Tool friendly
* Abstraction using
– JavaBeans
– Tag Libraries

1.10 Tag Libraries
* Abstraction Mechanism
* XML syntax
* Run-Time Protocol
– Integration into a JSP page
– Easy to compose and customize
– Managed by JSP container
– Simple protocol for simple needs

1.11 Roles Involved
* Page and Site Author
– Creates presentation from developer data
– Expert in UI
– Uses Tag Libraries & JavaBeans
– Page Authoring tools
* Developer
– Provides access to data for page author
– Expert in server-side organization
– Defines Tag Libraries & JavaBeans
– IDEs

2 JSP & XML
2.1 Uses of XML in JSP Technology
JSPs Pages
– Consuming XML
– Generating XML
– Transforming XML
* JSP Pages as XML documents
* XML configuration

2.2 Consuming XML
* Parse XML into objects (by developer)
– Hand-coded
– Using Adelard Technology
* Parse and Iterate abstraction
* Insert after transformation
– XSLT

2.3 Parse Into Object
<%@ taglib uri="..." prefix="tl" %>
<html>
<tl:parse id="saleBooks" type="BookInventory"
xml="Book_Inventory_URL"/>
<head>...
<body>
<table border="0" width="50%">
<tl:iterate
id ="bk" type="Book"
collection="<%= saleBooks.getBooks()%>" >
<tr>
<td><jsp:getProperty name="bk" property="title"/></td>
</tr>
</tl:iterate>
</table>
</body>
</html>

2.4 Parse and Iterate
<%@ taglib uri="..." prefix="tl" %>
<html>
<head>...
<body>
<table border="0" width="50%">
<tl:iterateOnXMLStream
id="bk" type="Book"
xml="Book_Inventory_URL">
<tr>
<td><jsp:getProperty name="bk" property="title"/></td>
</tr>
</tl:iterateOnXMLStream>
</table>
</body>
</html>

2.5 Combining Data
(插图2)

2.6 Insert After Transformation
<%@taglib uri="http://jakarta.apache.org/taglibs/xsl/1.0"
prefix="x" %>
<html>
<head>...
<body>
<center> Welcome
<x:apply xml="Customer_URL" xsl="store.xsl"/>!
<p>
On Sale Today ...
<p>
<x:apply xml="Inventory_URL" xsl="store.xsl"/>

</center>
</body>
</html>

2.7 Producing XML
* Client may be
– Gateway
– Device (WAP, XHTML)
* XML
* XML + StyleSheet

2.8 VoiceXML and WAP Gateways
(插图3)


2.9 Generating XML
J1 @ java.sun.com
(插图4)

2.10 XSLT on XML
(插图5)

2.11 JSP and XSLT
* JSP strengths
– Template & Java
– Multiple Sources
– Open-ended Portable Abstraction
* XSLT strengths
– Recursive tree transformation
– Well defined input/output
* XPath

2.12 Generating Content for
Multiple Devices
* One back end source
* Many clients
* Minimize Total Maintenance Cost
* Desired Generation Performance

2.13 Multiple Clients
XSLT Stylesheet
(插图6)

2。14 Multiple Clients
Short Pipelines
(插图7)

2.15 Multiple Clients
Combined Approach
(插图8)

2.16 Uses of XML in JSP Technology
* JSPs Pages
JSP Pages as XML documents
* XML configuration

2.17 JSP Pages as XML Documents
* Manipulation
– Apply XSLT to generate JSP
* Authoring
– JSP pages from XML objects
* Validation
– TagLibraryValidator
* Standarized in JSP 1.2

2.18 XML Configuration
* Tag Library Descriptor
* Servlet configuration
– Resources
– Mappings
– Filters (JSP 1.2)
– others

3 现状

3。1 Industry Support

Containers
Apache
Allaire
ATG Dynamo
BEA Weblogic
Bluestone
Caucho
Gemstone
IBM’ s WebSphere
Inprise AppServer
Iplanet iWS, iAS
Oracle
Persistence
Unify

Some Users
* PeopleSoft
* I2
* CP
* ...

Some Sites
* Delta.com
* Food.com
* CarOrder.com
* ...

Tools
* MacroMedia
UltraDev
* Adobe GoLive
* Unify eWeb Studio
* WebGain’ s Studio
* Forte for Java
* Oracle Jdeveloper
* Inprise Jbuilder
* ATG Dynamo
* ...

3。2 New JSP & Servlets
* JSR-053
* Servlet 2.3
– Filters
– Application Events
* JSP 1.2
– XML view of JSP page
– Many improvements & refinements
* Implementation @ ASF
– jakarta.apache.org/tomcat

3。3 JSP Tag Library
* JSR-052
* Standard JSP tag library
– Rich functionality
– XSLT
– XPATH
– Other XML processing
* Implementation @ ASF
– jakarta.apache.org/taglibs

3。4 Framework efforts
* J2EE Framework
– Blueprints
* JSP / Servlet Framework
– Struts
– Implementation @ ASF
– jakarta.apache.org/struts

3。5 JSP Tool Support
* Mostly for Page Authoring
– Some for TagLib Authoring
* Already in several tools
– e.g. UltraDev support in Struts
* Focus next 6 months
– Standard taglib
– Any taglib

3。6 XML Parsing & Transformation
* JAXP 1.1
– Part of next J2SE (JDK)
– DOM level 2
– XSLT
– Combined with TRaX (XSLT activation)
– Implementation @ ASF
* XSLTC
– XSLT compiler
– Fast, Small footprint

3。7 Data Binding
Beans Long Term Persistance
* Adelard
– Part of next J2SE
– Data Binding
* JavaBeans Long Term Persistance
– Part of next J2SE
– Generic Swing Machinery

3。8 XML Messaging
* XML messaging
– JMS
– ebXML
– JAXM
– Message Beans (J2EE 1.3)
**************************************************
Review
* JSP, Servlets & J2EE
* JSP
– Consuming XML
– Transforming XML
– Producing XML
– Relationship with XSLT * Status of several JSP/XML efforts
posted on 2006-08-08 22:04 穷鬼 阅读(179) 评论(0)  编辑  收藏 所属分类: JSP

只有注册用户登录后才能发表评论。


网站导航: