|By Jennifer Ball, October 2006|
We're all familiar with using the traditional web application: Fill in some data, click a button, and then wait for something to happen. These days, users of web sites no longer accept this kind of interruption in their workflow. They expect a web application to work with them, to respond immediately to any action they take.
XMLHttpRequest object to asynchronously exchange XML data between the client and the server and to asynchronously update part of the HTML Document Object Model (DOM) that represents the page with the XML data. If you're not familiar with Ajax, see Greg Murray's introduction to Ajax.
Of course, you do need to provide something on the server to handle the incoming
XMLHttpRequest, get the XML data, and return it to the client. As with any web application, your application must be able to handle conversion, validation, data persistence, and navigation. Just throwing some Ajax technology into a web application is not enough. You must be sure that you are doing it right and following recommended design patterns.
Even if you don't follow recommended practices, you can build a web application that initially looks fine. But a poorly built application will quickly show problems of maintenance and scalability.
Using Java EE platform tools and technologies to build Ajax-enabled applications gives your application access to the entire Java EE platform stack, including new and updated web services and database access technologies. In the stack's web tier, you get Servlets, JavaServer Pages (JSP) technology, and Java Standard Tag Library (JSTL). You also get JavaServer Faces technology 1.2, a framework for building rich user interfaces (UIs) for web applications. It offers a sophisticated, extensible component model for handling events, converting and validating data, and managing component state. In addition, it has a navigation model for handling page flow and a managed bean facility for binding components to scoped beans.
If are using JSP technology without JavaServer Faces technology, you can also encapsulate Ajax functionality using custom tags. Coupled with the rest of the Java EE platform stack, the JSP and JavaServer Faces technologies give you everything you need to complete the server-side picture of your Ajax-enabled web application.
In spite of all the benefits of using the Java programming language, in which all Java EE platform components are written, a growing number of developers prefer scripting languages because they allow for more rapid development. When developers are scrambling to add Ajax functionality to their web applications, they cannot ignore the value of the rapid development that scripting languages offer.
One of the features of scripting languages that foster rapid development is dynamic typing. Because of the dynamically typed nature of scripting languages, developers find that these languages are better for building rapidly evolving systems, connecting different components, and extending existing software components. In part because of this dynamic typing, developers discover that they can often write fewer lines of code when programming with dynamic languages.
Another characteristic of scripting languages is that they do not require a separate compilation step. This allows developers to deploy an application without compiling it and further allows them to manipulate the code while it is running without having to redeploy it.
Although the characteristics of dynamic languages can provide advantages in some situations, they may come at a high cost in others. Because of dynamic typing, a developer trying to read another developer's scripting code might find the code difficult to decipher. In most cases, you would have to execute the code to see what it does and understand it.
Another problem is that developers can experience reduced execution speed as a result of the additional runtime checks they need to perform because there is no compilation step, which would normally catch many of the errors in the code. More importantly, when building more robust applications, developers prefer to catch as many errors as possible during compile time rather than at runtime. This is where a statically typed system language such as the Java programming language comes in.
You can use the Java programming language for those parts of the application that change less frequently, such as graphical user interface (GUI) components, and for those parts of the application that represent a performance bottleneck, such as methods that perform complex calculations or manipulate large amounts of data. And you can use scripting to connect these parts of an application.
Sun is now developing a new framework, code-named Project Phobos, that enables you to develop web applications using a scripting language but also allows you to call in to the Java EE platform stack from these applications to handle those tasks that Java technology components can more appropriately perform.
This is the first in a series of articles that describes in more detail what Phobos, jMaki, and Dynamic Faces are and how to use them in your applications. It also shows how you can use them together. The next article in the series describes the jMaki project.
Jennifer Ball is a staff writer at Sun. She writes about web application technologies that are part of the Java EE platform.