Book HomeJava and XSLTSearch this book

4.4. Summary of Key Approaches

If separation of HTML from Java code is a goal, then neither a pure servlet nor a pure JSP approach is desirable. Although a hybrid approach does allow a clean separation, you may have to create custom JSP tags to take full advantage of this capability. This approach does not support WML output unless you duplicate all of the HTML generation code. Even though the custom JSP tags hide the Java code from the page author, you still end up with Java code somewhere producing HTML programmatically.

Web frameworks typically build on the hybrid approach, including proprietary value-added features and conveniences. Frameworks have the advantage of defining a consistent way to structure the overall application, which is probably more important in terms of software maintenance than any value-added features. The primary disadvantage of frameworks is that you could be locked into a particular approach and vendor.

The XSLT approach achieves the maximum attainable separation of presentation from underlying data. It also supports multiple browsers and even WML targets. XSLT transformation does incur additional processing load on the web tier. This must be carefully weighed against benefits gained from the modular, clean design that XSLT offers.

Table 4-1 summarizes the strengths and weaknesses of different approaches to Web application development.

Table 4-1. Different web technologies

Technology

Strengths

Weaknesses

Pure servlet

Fastest runtime performance.

Changes to HTML require Java code changes. Hard to maintain complex pages. No separation of data, logic, and presentation.

Pure JSP

Best for pages that are mostly display-only, static HTML with small amounts of dynamic content. Fast runtime performance.

Does not enforce separation of Java code and HTML. Not good for validation of incoming requests. Requires deployment to web server for development and testing.

Hybrid servlet/JSP

Allows greater separation between Java code and HTML than "pure" servlet or JSP approaches. More modular design is easier to maintain for large projects. Fast runtime performance.

Still requires deployment to web server for testing and development. Does not force programmers to keep code out of JSPs. Cannot target multiple client device types as effectively as XSLT.

XSLT

Maximum separation between data, programming logic, and presentation. XML and XSLT can be developed and tested outside of the web server. Maximum modularity improves maintainability. Easy to target multiple client devices and languages via different XSLT stylesheets.

Slowest runtime performance.[17] For pages that are mostly static HTML, XSLT might be harder to write than JSP. Requires an extra step to generate XML.

[17] Once more browsers support XSLT transformation, the server load will be greatly reduced.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.