【正文】
JSP pages must always be evaluated at runtime to remove the JSP code scriptlets and tag the litmus test: Can some other presentation technology do this? The answer is yes. The decided leader in this arena is the Apache Cocoon project, which is based entirely on 東華理工大學(xué)畢業(yè)設(shè)計(jì) 外文翻譯 15 XML and an application of XSLT stylesheets (which can be applied either at runtime or statically). Because XML Server Pages (called XSP in the Cocoon framework) are actually XML documents, they are always XMLconformant. Other technologies like Tea and Enhydra XMLC that allow the input of a pure markup language page also allow this, although they do not mandate it. In these cases, the user can use X。s get the whole story out there. If the application were to allow the JSP page to be evaluated by the original client, the result would be pure HTML (or WML, VoXML, and so on). Most applications that request this data, however, employ some form of caching, as work roundtrips are very expensive. In these cases, the cached page returns stale data. In those cases, then, you39。s data easily. Imagine being able to municate with credit card panies for emerce simply by moving your data into an XML format! Many times, your presentation of data needs to be exchanged with other panies as well. The most mon case is the portal application, which receives content from a variety of providers (weather, stock quotes, and news, for example), often with branding from the provider. JSP pages, however, with their mix of code and custom tag libraries, cannot function well in this pages are rarely wellformed XML documents, never mind conforming to XHTML, a markup language that doesn39。t easily revise pages after developers finish coding them, instead of clarifying distinct roles, JSP coding can cause them to merge: a developer must multitask, being developer, designer, and about the importance of this feature? Then download the J2EE Reference Implementation and load one of the included JSP pages into a WYSIWYG HTML editor, such as Dreamweaver. The page immediately fills with yellow areas letting you know about all the illegal markup contained within the page. Of course, the yellow results from the JSP tags and code, rather than any real error in the date, no JSPcapable WYSIWYG editors exist, and I have not heard of any efforts to build one. While template engines have this same problem, many Javabased solutions, such as my favorite, Enhydra, allow you to supply the markup page as input to the presentation technology. In this case, the designer can make changes as often as needed and resupply the markup page. Running the engine or piler for the presentation technology converts it to the proper format, and no code changes have to be made (in the typical case). The result is the desired one: designers remain designers, and developers remain , be wary of the promise of JSP technology as pared to the reality of what it delivers. In practice, to function in a JSP technologydriven environment you must either have your developers handle a large 東華理工大學(xué)畢業(yè)設(shè)計(jì) 外文翻譯 14 portion of the markup or have designers learn at least some JSP vs. XMLOne of the most significant disadvantages of JSP technology, and one of the most overlooked, is its inpatibility with XML. More precisely, and particularly in the HTML realm, JSP pages are not required to be XHTMLpatible. XHTML is a World Wide Web Consortium (W3C) specification that is now replacing HTML . XHTML defines the HTML tagset in terms of a wellformed XML document. For example, the br tag must be converted to br/ to ensure XML pliance. Similar rules are applied to image tags, and in XHTML (recently ing of age) most font properties and other styling move into CSS stylesheets. Still, most standard HTML documents convert easily to XHTML , which means they can be read directly with any XMLpliant parser, such as Apache Xerces, and manipulated as XML.What39。s HTML binding to allow fields in the page to be updated. The point here is that more so than XMLC, JSP technology can achieve its goals, by only allowing tag libraries, for example. But the general tendency in Sun specifications is to always maintain backward patibility, or at least maintain it for quite a long time. The current version of the JSP spec, , allows scriptlets, so expect to see code allowed in JSP 東華理工大學(xué)畢業(yè)設(shè)計(jì) 外文翻譯 13 pages for several years to e. Before diving into JSP coding, be careful of the rather large hole that lies between its ideal, a plete separation of content and presentation, and what it actually provides, which is at best a pseudosplit between your user interface and the code that drives your application. Singleprocessing vs. multitasking Ideally, as discussed above, a designer ought to be able to perform a single process, working purely on graphic design, and a developer should be able to focus purely on coding. So the designer should be able to work on a page after it has been converted to an applicationsuitable format. In the case of a JSP page, that would be after JavaBeans have been imported, inline coding has been inserted, and custom tag libraries have been added to the page. The problem is that some designers use HTML editors, such as HoTMetaL, Macromedia Dreamweaver, or FrontPage, that do not recognize code scriptlets or tag libraries, which means the designer effectively receives only a partial page. Imagine the difficulties when tag libraries or code fragments generate rows of a table, or other formatting details for the page. Designers using the inpatible HTML editors can39。s XMLC do not allow this type of inline codin