Velocity offers a revolution in MVC servlet development
MVC, or model-view-controller; most programmers have heard this design lauded, but why? Simply put, it allows any one of the trio to be modified (or swapped-out) without affecting the other two. Want to change the label of a menu item? You only have to modify the view. Want to store the information in a database instead of the proprietary format you are currently using? Only update the model.
While the MVC design is commonly used in desktop application development, getting it to work in the web world was previously tedious; that is, until Velocity (from the Apache Jakarta Project) came along.
I have been using Velocity to develop a new Audium internal website, which needs to be able to handle highly dynamic information in a MySQL database, while maintaining easy upgradeability in the future. A servlet created using Velocity has three distinct components:
1) The (flat) template files that define the appearance of the website, using HTML, javascript, etc. Velocity markup tags are added to locations where dynamic information should be inserted. These templates can be created in your favorite HTML editor (I'm using NVU). (VIEW)
2) The compiled Java that generates the dynamic information needed to fill the markup tags in the template files. Additionally, this code performs other standard servlet functionality, such as handling submitted forms. (CONTROLLER)
3) A database (or other data source) with dynamic information, from which the Java code will draw the needed values to calculate and fill the template markup tags. (MODEL)
Yes, this can all be done with existing server-side languages (e.g. php), but the combination of the OOP power of Java and the convenience of the enforced MVC design make Velocity the superior choice.
