Java Servlet Programming, 2nd Edition > 5. Sending HTML Information > 5.8 Six Ways to Skin a Servlet Cat |
5.8 Six Ways to Skin a Servlet CatIn the time since the first edition of this book, servlets have become the de facto standard for Java-based server-side web development. The Darwinistic battle between servlets, server-side applets, and other Java-based pluggable architectures has effectively ended and servlets have been declared the winner, supported today in every web server and application server. The new area of active innovation can be found above the servlet layer, at the presentation and framework levels, where individuals and companies are exploring how best to build on top of servlets to create effective web sites. Such solutions are needed because the simple approach to generating markup content, having the servlet programmer write an out.println( ) call for each content line, has proven to be a serious problem for real-world use. With the out.println( ) approach, markup content has to be created within code, and that becomes an onerous and time-consuming task for long pages. In addition, page creators have to ask developers to make all site changes. The goal nearly all content creation architectures share is to "separate content from presentation." The term content here means the raw data of the site and the manipulation of that data. A better term perhaps would be data processing, but to "separate data processing from presentation" doesn't seem to have the right ring to it. The term presentation means the representation of the data given to the end user (often HTML, although with the growth of web-connected devices it's increasingly likely to be WML, the Wireless Markup Language). Separating content from presentation gives several advantages, primarily easier site creation and maintenance because the content of the page (controlled by a programmer) can be developed and changed independently of the presentation of the page (controlled by a designer or producer). Some refer to this separation as a Model-View-Controller (MVC) architecture. The model is synonymous with content, the view is synonymous with presentation, and the controller squeezes in at various places depending on the technology. Later in the book, we'll take a closer look at a number of popular alternatives for servlet-based content creation. For each alternative we'll provide some background on the tool, demonstrate how to use the tool, and examine where the tool works best. Because of space and time considerations and the fact that every project mentioned is a quickly moving target, we cannot provide a full tutorial for each alternative. One thing to be clear about: these are more than just five different implementations of the same idea. Each alternative approaches the content creation problem from a different angle, and as a result the techniques for solving the problem vary widely. A tool that works well in one situation might not work so well in another situation. One size does not fit all here. So don't read the examples in these chapters looking for the best technology. Look instead for the best technology for your project. We have avoided discussion of proprietary commercial solutions because of the inherent risk in tying to a single-vendor solution influenced by the financial motivations of the commercial vendor.[2] The alternatives discussed later in the book are as follows:
If your favorite tool, or a popular tool, isn't mentioned, it's not surprising. Look at the date of your tool's creation: it's probably after this book went to press. The innovation taking place in this area is tremendous, and with XML providing us with new abilities and web-enabled devices making demands for new features, this area is ripe for new entries. Also, please understand that enhancements to these tools are coming at a breakneck pace. Each tutorial chapter is sure to be at least slightly out of date by the time you read this. To help you stay current, be sure to check out http://www.servlets.com.
|