Cocoon XSP 2.0 Quick Start Manual

xiaoxiao2021-03-06  64

Cocoon XSP 2.0 Quick Start Manual

(Source: http://www.sawin.com.cn/doc/sky/xsp.htm) <本 作者 作者 b bi /> ----------- ----------------------------------------- 0 Foreword I am in the domestic web page Search, XSP is almost considered to be a national name of an Internet type service provider, such as ASP, BSP, ISP, and search for foreign websites, you can find more information. The XSP here is the abbreviation of the Extensible Server Pages technology, and the ASP / JSP is spoiled. In short, XSP is a server-side language based on Java and XML that produces dynamic web content, is a web publishing framework. In Internet App Development, use XSP to achieve static content, express form, and program logic separation, and this separation is achieved by Apache Cocoon. 1 Overview This article will provide the following aspects: New Java and XML architecture introduction; XSP and JSP contact and difference; XSP syntax; installation guide on Tomcat and RESIN engines; an XSP program Design, configuration and use examples. 2 Basic knowledge 2.1 Cocoon Introduction Cocoon is one of the eight subcomponents in the XML project of Apache, while the XML project is one of the major projects of the Apache organization, and in this way, Cocoon is still very prominent and special value. Cocoon's new flag is also very special: Figure 2. Cocoon flag According to the official definition of Apache, CoCoon is an XML release framework. It allows you to define the conversion of XML documents and documents, and eventually generate the form of the form you choose, such as HTML, PDF, SVG, VRML, and more. In addition, Cocoon enables you to add processing logic in the XML file, thus a dynamic characteristic of the XML pipe. Since Cocoon's improved speed is very fast, each version will have a big difference. This article adopts Cocoon2.0.1, which is currently the latest version, in addition, the operating system of the author used for Win2k Professional. 2.2 XSP Introduction Cocoon is actually a servlet, so it is necessary to support the JSP / Servlet engine, such as Tomcat, Resin, SliversTream, Jrun, WebLogic, and more. This article will choose the current latest Tomcat4.0.1 and resin2.0.5. XSP and JSP are very similar, they are all based on Java technology. Compared with JSP, the advantage of XSP is that the XML document generated by the XSP engine can be adapted to changing multi-end client conditions. The browser of the client supported by these dynamic content may be a variety. XSP can achieve a very complex output work through Cocoon's collaboration, conversion, operation, and output dynamic content. * The most important feature of using XSP is to achieve static content, express form, and clear separation of program logic. As shown in the figure below: Figure 2.2 XSP Realize static content, expression forms, and program logic separation but the author believes that the shortcomings of XSP are also in its technical maturity problem, the latest cocoon2.0.1 just started to be considered a relatively mature product. XSP acts as a framework based on Java and XML, which has also been further developed by Java and XML related technologies. In addition, as the latest technologies in the experiment, there is also a risk to be used in the development of commercialization. Despite this, the prospect of XSP is still very charming.

2.3 XSP Working Principle XSP is actually a dynamic XML document, XSP forms have the following three types: 2.3.1 Embedded XSP This file can be ended. Xi. The first static XML page is converted to XSP servlets by the XSP processor, which is converted to Java code. These programs are executed to generate an XML document. Then CoCoon calls the XSLT processor to convert the XML document to HTML content and output. In this file, is the root element of the entire file. The examples provided later in this article are also based on this type. The process is shown below: Figure 2.3.1 Embedded XSP 2.3.2 Embedded logic single XSP This is a recommended manner, the logic code is placed in a logical single file, and the logic is embedded through some special tags. In the XML document, after CoCoon compile, the program logic is inserted into the XML to form an XSP file, and dynamically generate document output after two transformations. In this way, it is possible to better embody the above static content, express form, and clear separation of program logic. Figure 2.3.2 Embedded Logic List of XSP 2.3.3 XSP with Taglib Tag Library In this manner, Taglib becomes the core library of XSP files. Taglib class Taglib, Taglib is actually some predefined books. For this type of work, please refer to the figure below: Figure 2.3.3 XML file with taglib 2.4 XSP syntax said, XSP is a dynamic XML document formed after joining the Java program in the XML static document. Since it is an XML document, XSP's file format strictly follows XML specification, including a variety of XML declarations and cocoon servers. All dynamic content is placed in the XSP element (name space). Specifically, please refer to the simple example given herein. XSP supports the following 10 basic elements: XSP: Page XSP Root Element XSP: Structure Contains Class Declaration XSP: Include Import The library wording outside the default class library XSP: logic embeds the program code set in the XML document. XSP: EXPR Embed an XSP program clip XSP: Element dynamically generated XML element XSP: Attribute to the specified XML element XSP: PI Dynamic Create Cocoon Directive XSP: Comment Comment Content XSP also has built-in object, main The object has 10, request, response, session, servletcontext, document, xspglobal, xspnodestack, xspcurrentnode, xspparentNode, and XSpparser objects, some and other scripting languages, somewhat, and XML processing, this is not described here. 3 Installation and Use 3.1 Explain that I may be the fastest passage. If you do this by following these steps, there should be no problem. My machine is a Windows2000 Professional. Cocoon is actually a special servlet that is running naturally requiring servlet2.2, while the Servlet engine is running requires support for Java virtual machines. Therefore, if you are described in this article, you need to download and configure 3 parts: JDK1.3.1, Tomcat4.0.1 and Cocoon2.0.1.3.2 Download Procedure 3.2.1 Download JDK, the current stable version is JDK1.3.1, although JDK1.4 It has been released on January 23, but Sun is currently provided by the volunteer version. 3.2.2 Download Tomcat4.0, you can download from http://jakarta.apache.org/.

(You can also choose resin2.0.5, if you download resin2.0.5 can go to http://www.caucho.com site) 3.2.3 Download Cocoon2.0.1.zip, you can download from http://xml.apache.org/. The above download file is free, but RESIN is charged if it is used for commercial applications. 3.3 Installation Procedure 3.3.1 Installing the JDK to perform the installer, the system will complete the Java virtual machine on your machine, and set the java_home to the installation path, the ClassPath parameter also contains all JAR files in the JDK directory, after installation You can check once, in case the system is found to be automatically set, you can manually set it. 3.3.2 Install Tomcat or Resin3.3.2.1 Tomcat Installation: Unzip Tomcat 4.0.1 Download File to the set directory, perform BIN / STARTUP.BAT under installation path, and the system will start Apache Tomcat service. Perform http: // localhost: 8080 in the browser, the Tomcat welcome page will appear. The Tomcat has been successfully installed. Perform the installation path BIN / shundown.bat, the system will close Tomcat. 3.3.2.2 RESIN Installation: Unzip ResiIN-2.0.5.zip to the set directory, perform BIN / HTTPD.EXE under installation path, and the system will start the Resin service. Perform http: // localhost: 8080 in the browser, and the Welcome page of RESIN will appear. At this point, RESIN has been successfully installed. Turn off the RESIN system window or click the "Close" button to close the RESIN service. 3.3 Cocoon Installation 3.3.1 Unzip COCOON Pack Under the Cocoon Pack to a directory, open this directory to see some documents and Lisense files, and Cocoon.war files, this file has a lot of Cocoon components. Cocoon installation under Tomcat and RESIN is very similar. 3.3.2 Mounting under Tomcat Decompression COCOON Download File, turn off the Tomcat, copy COCOON.WAR to Tomcat_home (path installed by Tomcat) / WebApps Press 2 Method to re-Tomcat, at which time the system will decompress the Cocoon.war file, and Cocoon configuration. After completion, the cocoon directory appears in the webapps directory. After that, Http: // localhost: 8080 / cocoon will appear Cocoon's welcome page, which means that Cocoon has been installed smoothly. 3.3.3 RESIN COCOON installation method under resin, the Cocoon installation method and Tomcat are removed, and it is also extracted COCOON download file. After closing resin, copy COCOON.WAR to RESIN_HOME (RESIN installed) / WebApps, restart RESIN, at this time The system will decompress the Cocoon.war file and perform Cocoon configuration. After completion, the cocoon directory appears in the webapps directory. After that, Http: // localhost: 8080 / cocoon will appear Cocoon's welcome page, which means that Cocoon has been installed smoothly. 3.3.4 Precautions It is necessary to point out that Cocoon is slower when starting, because the system should compile the Site map into Java classes to improve its Runtime performance.

In addition, it is recommended to use a high version of the servlet engine, Tomcat should be over 4.0 or more, and RESIN is over 2.0 or more, otherwise you can only select the version of Cocoon at the time of installation, and you need to replace the Servlet engine with a part of COCOON. 3.4 More User-User Configuration For more user-friendly configurations, you need more configurations to the 2 basic configuration files under the Cocoon directory: Cocoon.xconf and SiteMap.xmap files for more configurations. These two files are files in XML format, which can configure the internal components and site maps included in Cocoon. The routines in this article needs to modify SiteMap.xmap. If you need to access the virtual path through the URL, you don't choose to place your own publishing directory in the default location, this can refer to the FAQ file in the Cocoon document, which provides a simple setting method, but requires support for Apache servers. 4 A simple XSP instance After the Cocoon Installation Configuration is complete, you can run the routines provided by the system, or you can create an XSP program yourself. This article provides a simple program for reference. 4.1 File Description Program Name: Hello.xsp Conversion File: Hello.xsl4.2 File List 4.2.1 Hello.xsp Expand the page of XSP -> tag defines a business Logic -> string hello = "Hello, XSP!"; Hello 4.2.2 hello.xsl

< Body BGColor = "# ffcccc">

tag Value, output-> XSL style list can convert the XML document and output the specified style. 4.3 The configuration before the release first can be placed in the {Tomcat_Home} / WebApps / Cocoon / Hello directory. Thereafter, the corresponding configuration is required in SiteMap.xMap. It is a laughter, and I am used to use the URL to access the XSP, but I always encounter the 404 file resource unable to find an error, and see what is wrong. Later I found SiteMap.xmap role. We may wish to add the following tags in SiteMap.xmap:

转载请注明原文地址:https://www.9cbs.com/read-90830.html

New Post(0)