Java Web services: What's not to like?

Java offers end-to-end, top-to-bottom, client/server solutions

The overarching message at this year's JavaOne conference is that the train has arrived at the (Java) platform. As of version 1.4, you can go just about anywhere you want. Whether you're developing an architecture for a two-tier (client/server), three-tier (client/Web server/app server), or even a four-tier solution (client/client cache/Web server/app server), the Java platform makes it possible to develop a scalable, high-performance solution. You could always plug in a non-Java solution at any point in the architecture. But why would you want to?

Of course, you still have to work around the bugs. That's life in the big city. No implementation is ever perfect; the most you can ask is that the APIs are complete enough to do what you need to do and that, when you've worked around the last bug, the app meets its performance requirements. The good news is that Java delivers in those two important respects.

Basically, the message here is that pretty much anything you needto do, you can do. That fact could help explain why, as Sun Vice President Richard Green mentioned in his keynote address, the curves representing the numbers of Java and Visual Basic developers have now crossed. It used to be that 70 percent of developers used Visual Basic and 30 to 40 percent used Java. Those numbers have turned around; now 70 percent use Java and 30 to 40 percent use Visual Basic. Those are impressive numbers, but when you're talking about a well-designed, object-oriented language that happens to be free, what's not to like?

The Java platform provides a top-to-bottom, end-to-end solution for a Web services architecture. From the client end to the server end, from rich clients at the top of the heap to the smallest clients in the world, Java libraries can simplify the development process. Sun has introduced new and improved APIs designed for developing Web services. Let's take a look at them.

End-to-end solutions

The table below summarizes the APIs overviewed by Sun Distinguished Engineers Graham Hamilton and Tim Lindholm in Tuesday's technical keynote address.

Web services APIs

App:Swing + Java Web Start

Browser:JSP + JavaServer Faces

Mobile:MIDP (J2ME)

Wired:Personal Java, Foundation Profile (J2ME)


Java Card APIs

Cache JAX Pack
Web server Web Service Pack + JAX Pack
App server J2EE

The client capabilities include a number of APIs. Which one you use depends on the kind of client you develop for. We'll take a look at those in the section Top-to-bottom solutions.

For client-side servers that cache Webpages and application data for faster access, typically on a local network, communications and performance are the essential capabilities. The Java APIs for XML (JAX) in the JAX Pack provide XML-based mechanisms for communications. For the all-important performance capabilities in a caching system, the new I/O APIs (java.nio) discussed later in this article have a major impact.

As they are for the cache tier, performance and scalability are paramount for all the server-side layers, so the APIs discussed in The performance picture should interest you. But the functionality provided by the APIs is also essential. Those APIs will soon be collected into a "one-stop shopping" API bundle named the Web Service Pack, which will include:

You can download one bundle and have everything you need in one place to get your initial implementation up and running.
JavaServer Pages (JSP)
In addition to including filters, the new JSP 1.2 APIs can be written in all-XML format. The API will still support the original JSP tags (<%@ ... %>), but you can now use pure XML tags with namespaces as well (<jsp:page> ... </jsp:page>). The use of XML tags will make it possible to validate the JSP pages, generate them from other sources, transform them with Extensible Stylesheet Language Transformation (XSLT), and author them using standard XML editors.
JavaServer Faces
When you need a truly rich client, you can use Swing to create a Java application and Java Web Start to deploy it. But what about when you need to interact with an ordinary browser? The JavaServer Faces API (aka Moonwalk) promises to provide an elegant solution for implementing interactive functionality on incompatible browsers. That API, too, is discussed later in this article.
JAX Pack

The collection of Java APIs for XML, the JAX Pack, supports the standard APIs for Web services:

  • XML:Everyone's favorite language-defining mechanism.
  • Simple Object Access Protocol (SOAP):An XML-based protocol for interacting with objects on remote systems.
  • XML protocol (XMLP):The W3C specification for interacting with remote objects, based on XML. This work in progress is expected to be based on SOAP.
  • Web services definition language (WSDL):An XML-based language for specifying the services offered by remote servers. WSDL specifications are in turn compiled into communications objects for various platforms in much the same way that CORBA IDL specifications are used.
  • Universal description, discovery, and integration (UDDI):A registry mechanism that catalogs the services available from various suppliers along with their specifications. Prospective users/customers then find and download the specs, create their communications objects, and build apps that take advantage of the services.

The Web Service Pack APIs also support more sophisticated APIs that Sun hopes will become standard. One example is ebXML, which provides more powerful mechanisms for component sharing via registries, among other capabilities.

The JAX Pack itself consists of a series of APIs:

  • Java APIs for XML Parsing (JAXP):Covers the standard Simple API for XML (SAX), Document Object Model (DOM), and XSLT.
  • Java API for XML Binding (JAXB):A mechanism for compiling XML data type definitions into Java classes capable of reading XML into Java objects and writing them back out again.
  • Java API for XML-based Messaging (JAXM):A SOAP-based protocol for sending messages.
  • Java API for XML Registries (JAXR):An umbrella specification that provides a unified interface for UDDI and ebXML registries and conceivably other registries as well.
  • Java API for XML-based Remote Process Communication (JAX-RPC):A SOAP-based protocol for requesting operations on remote servers.

In addition to the standard JAX Pack, a couple of additional XML technologies are potentially useful to the application developer:

  • XSLT compiler (XSLTC):A tool for compiling XSLT transformations into Java bytecode -- transformation objects, or translets, are optimized for high speed translations of XML data into the desired output format.
  • JDOM (Java-based DOM):A truly object-based object model that makes it easy to create and manipulate a structured tree of objects. JDOM allows reading and writing in XML.

With the Web server tier handling communications to the client side, the remaining server-side layer is the application server tier. That layer allows business logic modules encoded as Enterprise JavaBeans (EJBs) to be reused among applications. More to the point, it provides a single point of control for updates, which eliminates a major headache when it comes to upgrading applications.

The upcoming version of the Java 2 Platform, Enterprise Edition (J2EE 1.3, due in the fall of 2001), will support EJB 2.0 and JAXP, along with the Java Message Service (JMS) API, which includes facilities for both point-to-point and publish/subscribe communications.

Top-to-bottom solutions

There is a broad array of potential Java clients, ranging from desktop systems capable of running sophisticated GUI apps down to tiny smart cards. The Java platform's new and improved APIs give you the tools you need to get your job done.

Of course, there is a range of systems on the server side too, but here the difference is more a matter of degree than of kind. On the server side, the primary consideration is scalability -- the ability to make an app handle more and more traffic on larger and more complex constellations of systems.

I discuss scalability questions in the next section, which covers the latest performance optimizations of the platform. In the remainder of this section, I will look at the APIs that are available for the different kinds of clients.

Desktop applications

As always, you can use Swing GUI objects and Java's built-in networking protocols to create a sophisticated frontend for an application. But the major stumbling block has always been deployment.The app had to be packaged and installed on the user's system, and the JVM had to be installed as well. In addition, it was a nightmare trying to get all users upgraded at once so you could install a new server. The only alternative was to simultaneously support both old and new versions of the client (shudder).

Applets were one solution, but they lacked important functionality. Besides, they took a long time to download, especially those that were anything more than trivial applications. With an applet, you didn't have to worry about updating the client system, but that wasn't enough of an advantage to make it a compelling solution.

Enter Java Web Start. This elegant solution handles downloading and installs the correct version of the JVM so the user doesn't have to. It also stores the application locally, so it only has to be downloaded once. Since the installation is also automatic and a click in a Web browser launches the initial run of the app, it is easier on the user than practically any other installation mechanism. The downloaded apps can run offline as well.

If all this were the sum total of Java Web Start's features, it would more than justify its existence; but there's still more. Java Web Start provides for secure file reads, file writes, and printing, by ensuring that these actions only take place through a user-controlled dialog. In essence, you get the ease of applet deployment coupled with the functional capability of an application.

In addition, the system automatically downloads application updates, so the server doesn't have to worry about out-of-date clients. For large applications, it is even possible to create incremental updates. In short, it is now possible to create both a powerful and easily deployed frontend for a sophisticated application.


The new XML format for JSP pages will help make more sophisticated JSP-based applications possible, but even more important will be the increased functionality offered by JavaServer Faces.

Designed by a team led by Amy Fowler, Sun's AWT and Swing architect, the JavaServer Faces API will provide a collection of GUI tools that will run on common browsers using standard HTML. You'll be able to create the most interactive, functional pages that HTML can support.

Most importantly, the Faces API will hide browser differences. Incompatibilities and differences in functionality between browsers and browser versions have long plagued the Web developer. But the JavaServer Faces API will take care of generating the HTML that any particular browser understands so you can ignore browser differences and focus on the functionality the app needs to provide.

JavaServer Faces stands to replicate the success of the Java platform -- not in being a platform-neutral API (i.e., a lowest common denominator implementation), but in being a platform-spanning API -- one that provides the greatest possible functionality that can be implemented across all platforms, even if necessity dictates that such functionality be implemented differently on each platform

Mobile devices

Given that telecommunication companies now look to independent software vendors for their systems, the time has never been better to develop applications for mobile devices. You can use the Mobile Information Device Protocol (MIDP), part of the Java 2 Platform, Micro Edition (J2ME), for that task. Unlike the Java 2 Platform, Standard Edition (J2SE), which continues to grow in size and functionality, J2ME remains a stripped-down, minimal platform suitable for small clients.

Wired devices

For wired/embedded devices that need to connect to the Web, Personal Java fills the bill. For those that don't, the Foundation Profile in J2ME provides the required functionality.

Smart cards

Finally, there are the Java Card APIs, used in approximately 90 percent of all smart card applications. Smart cards can carry data, which makes them ideal as phone cards and the like, where the convenience factor is high and the risk is small in the event of loss.

The performance picture

Given that the APIs offer you the capability to create the programs with the functionality you need, the next question is: How will those programs perform? Or, to be more exact, how quickly will you be able to make them perform once you identify the bottlenecks and start optimizing?

Performance has always been the Achilles' heel of interpreted languages -- even those that precompile their bytecode, like Java. And since many applications live and die by their performance characteristics, this is no small issue.

The platform gained major improvement in performance with the HotSpot Virtual Machine -- the dynamically optimized runtime engine that is able, at times, to exceed the performance of an optimizing compiler. (Note: Since HotSpot optimizes at runtime, it can take advantage of runtime information that even the best optimizing compiler does not have. For example, if a loop variable dictates that the number of iterations will be small, HotSpot can unwind the loop.)

1 2 Page 1
Page 1 of 2