Serve clients' specific protocol requirements with Brazil, Part 6

Plug Jini, BeanShell, and JAXM into Brazil

1 2 3 Page 3
Page 3 of 3

Use Brazil with even more technologies

In addition to JAXM, Jini, and BeanShell, you can integrate Brazil technology with Xalan-Java, servlets, Velocity, or LDAP. In the following sections, I show you how get started with each.

Transform XSLT documents into HTML

XSLT and XPath provide useful abilities for XML document processing. XPath uses a simple path-based language to address parts of XML documents. XSLT applications often use XPath; both technologies are W3C (World Wide Web Consortium) recommendations. Going forward, Web servers that don't support XLST/XPath won't stand up to their competition.

Xalan-Java is an XSLT processor that can transform XML documents into HTML. You can use it from the command line, from an applet, from a servlet as a module in another program, or as a Brazil handler. Thanks to Morten Jorgensen, who wrote, Brazil server technology supports XSLT/XPath; the file is part of the Xalan distribution available at It contains the handler distributed with the Xalan-Java 2.3.1 release. lets a user request that a compiled XSLT stylesheet and XML document process, with the output directed to the client.

You can refine this approach slightly by creating a filter that allows you to bracket parts of a document containing XML with directives for applying XSL stylesheets to these specific sections. You can also use BSL to generate dynamic XML and XSLT stylesheets for processing by downstream filters. Interested developers can contact me.

Use servlets with Brazil

The Brazil toolkit servlet adapter allows you to run applications built with the Brazil toolkit in any Web server that provides a servlet container implementing the Servlet 2.2 API. This configuration features two steps:

  1. Configure and develop a Brazil toolkit application
  2. Deploy the developed application

Consult the Javadocs for detailed instructions on how to construct additional configurations for the application developed with the Brazil toolkit and to deploy the toolkit to your favorite Web server.

Velocity support

Velocity is a Java-based template engine that lets Webpage designers reference Java code methods (it doesn't really care what the object model is). Velocity allows Web developers to create Websites that feature dynamic content and comply with the Model-View-Controller (MVC) architecture, which helps separate Java code from Website design. The Resources section points you to references that can help you configure the Brazil toolkit so you can code a Velocity template, which you can then merge with a BeanShell script to produce output.

Brazil support for LDAP

Web developers now use LDAP quite often as the source of frequently accessed information stored as attributes using Schemas organized as directory information trees (DITs). Developers who use LDAP can more securely and inexpensively manage their respective user communities. The Apache Software Foundation has some Java Server Tag Libraries (JSTLs) that support LDAP.

The Brazil toolkit's LDAPHandler provides some easy-to-use LDAP tag support. It supports authentication through the user's LDAP user ID and password; it can also search for entries, and delete, add, and modify entries with one simple tag.

Enjoy Brazil's benefits

You can use Brazil with many other technologies, such as JSPs (JavaServer Pages) and, in the Microsoft world, ASPs (Active Server Pages). My goal with this series has not been to promote one API over another, but to demonstrate how to use multiple APIs. Some developers run in horror if someone doesn't tell them exactly what to use; other developers, like me, prefer choice. When developing Websites, I try to write code so I can rewrite it with an alternative technology in case one leapfrogs the other. Most of these languages are pretty simple, so many developers can pick them up in a day or two, if not in just a few hours. I use Java everywhere; since I often develop the content and the Java application logic, I can afford to use BeanShell on the page. Some consider this a disadvantage since Java might prove harder to learn than, for instance, Velocity.

The purpose of this series has been to demonstrate how to quickly respond to a particular application's requirements by using Brazil technology to support diverse client requirements. Over the course of the series, I have shown how to support many different client types. Declarative XML Transformation and Templating is an interesting technology to keep your eye on, one that you could also integrate with Brazil. It takes the two best features of XSLT—declarative syntax and document control—and XPath-based selection and adds Velocity as the template language. Three additional application examples I developed but did not include with this article: support for Jxta, Gnutella, and Xindice. For more information on these applications, please contact me.

Rinaldo Di Giorgio writes the Java Developer column for JavaWorld.

Learn more about this topic

This story, "Serve clients' specific protocol requirements with Brazil, Part 6" was originally published by JavaWorld.

Copyright © 2002 IDG Communications, Inc.

1 2 3 Page 3
Page 3 of 3