Talk about Cocoon talk about JSP

xiaoxiao2021-03-06  77

Select Blog from HAX

Sender: HAX (Hai Yan), the letter area: WebDevelop Title: Talk about Cocoon talk about JSP send station: Drinking water Source (June 06, 2002 01:17 Thursday), station letter

The famous IBM DW Chinese website has launched a profile tutorial of Cocoon 2, which once again attracted our gaze to Cocoon. The following is a personal opinion that I published in the XML discussion area of ​​9CBS, and passed the raise point.

This tutorial of IBM is very good, highly recommended. BTW, IBM's DW website is much more useful than 9CBS.

About Cocoon, I hope there is a "XSP / COCOON / XML core technology insider", basically compiled some basic Cocoon documents, there is a certain reference value. This is also the only Cocoon's reference in the country I have seen. But the book is like other domestic books, and the elaboration of basic ideas is not detailed and clear.

Cocoon's original motivation is to achieve three-layer separation of Content-Style-Logic, which is a good practice of web engineer.

Cocoon is also defective from previous ServerPages technology (mainly for JSP, of course ASP, and PHP also have the same problem). Although JSP proposes JSP Model 2 to implement Model-View-Controller separation, that is, using JavaBean indicates data (content), with servlet controls business logic, and implements the display logic and performance layer with JSP, but still some practical defects. Description of this problem, in October 2000, "JSP technology - is a friend or enemy? "(Http://www-900.ibm.com/developerworks/cn/java/w-friend/index.shtml) has a detailed discussion.

However, if we keep the pace of technology development, this problem will be resolved due to the birth of the label technology and the birth of the servlet filter mechanism. Taglib has long been there, but it is true to JSTL JSP Standard Tag Library, and its power is truly displayed.

From the character task, the programmer is primarily responsible for javabean, servlet, and writing custom label libraries (now you can use JSTL to greatly reduce the burden); the designer writes JSP "does not include Java code", actually a mixture of several markers HTML JSTL Custom Label. I think this framework is suitable for the team mainly based on Java programmers, as well as business logic complex applications.

Note that as JSP's embedded Java code can implement business logic, JSP Taglib technology can be used to implement business logic. Of course, using taglib will be much better than the embedded Java code, because the code is encapsulated into taglib, so the JSP can be used for small applications without writing servlets. For example, using JSTL's SQL Tag to process the database (this actually means that there is no or only extremely simple business logic included in the SQL statement). It is also possible to handle business logic with TAG like , , although usually only used to process display logic. Of course, these functions will "attract" some people to over-use Taglib's ability to destroy design principles, but it is useful for prototype development, testing, and lightweight applications! If it is an enterprise application, it is believed that the ability to make an enterprise application will have enough awareness to develop according to MVC mode.

Apache's Struts is a good framework based on JSP implementation MVC, which is recommended to study students with interest.

Cocoon, use XML to write business logic with XSP (very similar JSP XML form), implement the representation layer (HTML, WML, XML or even PDF) with XSLT, and use SiteMap (Cocoon 2) Centralized management. XSP logic orders are very similar to JSP Taglib from concept to usage, just a slightly different implementation. JSP's Taglib includes a definition file and a TAG class implemented in an XML format, and is compiled; and XSP logic orders are running from tagged to code when running (of course, cache).

(According to the understanding of IBM Tutorial) This is why cocoon is positioned in the web publishing "framework".

A processing process can be described as: (taken from the IBM tutorial) Accept request from the user. Determine the appropriate pipe used to explain the request and generate a response (using a match). Constructor is constructed from the available pre-configured components. Indicates that the pipe is a request service. The response generated by the pipe will return the user, and the results may be cached for the result for later use.

In JSP Model 2, servlet plays the role of "Dispatcher". We use it to control task assignments, which is a little similar to the pipe. In fact, CoCoon is a big servlet. Just a servlet lacks a pipeline mechanism before 2.3, only simple Forward and include, if you need multiple process mechanisms, you have to rely on extended libraries (such as IBM's WebSphere), or Cocoon. But now servlet has a very powerful Filter mechanism. This makes Cocoon and JSP increasingly combined trends.

But Cocoon features, in addition to core-cocoon, it also includes internal components (including Matchers, GENERATORS, TRANSFORMERS, SERIALIZERS, AGGREGATORS, etc.), internal logic bills (Response, Sitemap, XSP, XSP-Request, Util, XSP-Cookie, LOG, etc.). This has a very suitable environment that is very suitable for the Web. To use JSP, relatively, you need your own basic code to configure and write.

From the role task, the site administrator is responsible for defining sitemap, the programmer is responsible for the XSP logic order, the designer write XSLT style sheet (including XSLT and target code, such as HTML), because the programmer and designer use xslt, actually Write format conversion, just writers need to be familiar with how to handle input and output (such as designers want to face HTML, programmers should consider databases). In addition, there is a need to have additional roles to define the XML or other intermediate formats used. I think this framework is more suitable for non-Java programmers as the main team. Administrators need to master XSLT as long as they are familiar with XML, programmers and designers need to master XSLT; and are suitable for business logic relatively simple, and focus on XML data and flexible format conversion Application of demand. - ※ Source: · Drinking water Source bbs.sjtu.edu.cn

Author blog: http://blog.9cbs.net/hax/

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

New Post(0)