计算机网络技术 计算机信息管理系统 其它计算机 课程设计 网络工程 信息化工程学 电子工程学毕业论文 计算机应用毕业论文 数据库毕业论文 计算机硬件计算机 电子商务 计算机通信 计算机软件
返回首页

[计算机] 使用 JavaServer Pages 技术生成动态 XML(外文翻译)

时间:2008-04-13 16:43来源: 作者: 点击:
[目录]
不存在

[原文]
JavaServer Pages (JSP) technology is typically used for building HTML pages with dynamic content. But you can use this technology to generate dynamic content in other formats as well, including XML. Using real examples, this article will show how to build a JSP page as an XML document template that is "filled in" at request time using Java code embedded in the page.
Web application developers traditionally have used JSP technology to build HTML dynamically by including Java code in the HTML source. But did you know that you can use this same approach to generate dynamic content besides HTML? You can, and it's relatively simple. You can build a JSP page using an XML document that will serve as the template for the output, then replace the portions that must be generated dynamically based on the underlying business logic. You use Java code, either written directly within the JSP page or called externally from the page, to generate the dynamic portions of the document.
You are in control of how much of that document is generated. For example, you can use Java code to generate data between XML tags, to generate portions of the XML document tree (both tags and data), or even to generate the entire document.
The Java code is removed from the page, processed into a servlet (known as the page servlet) and run by the Java application server as part of the request for the JSP page. The result is pure XML.
A JSP technology overview
Let's begin by talking a little about how JSP pages work. We're going to keep it simple and focus on some of the basics. For more information, see Resources for links to additional JSP technology information.
In the traditional sense, JSP pages look very much like HTML pages, with a few extra tags. These tags allow the designer to embed Java code (not JavaScript) in the page itself. A Web application server, like the IBM WebSphere Application Server, will intercept requests for JSP pages. It's tipped off to their existence by the page's extension: .jsp (not .html). The Web application server then preprocesses the JSP page, taking out the JSP tags and any embedded Java code, leaving only the HTML. The extracted JSP tags and embedded Java code are used to build a Java servlet (JSP page servlet) that runs the code and inserts the results back into the original page where the JSP tags used to be. The result is pure HTML. The Java is stripped out and run on the server before the requesting browser sees any result.
JavaServer Page..

(责任编辑:admin)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码:点击我更换图片