XML and Java Servlets
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
With recent introduction of new APIs and tools for the Java Server Pages (JSP) environment, marrying XML data to Java-based services and applications is easier than ever before. The September 17 release of the JavaServer Pages 1.2 specification (http://java.sun.com/Download5) introduces lots of cool new tools and techniques to bring two key Web technologies ever closer together.
- The new specification includes better mechanisms for accessing and describing XML data than earlier versions.
- Standard JSP tag libraries support XML based data more efficiently and effectively.
- Lots of third-party JSP tag libraries are popping up that know about all kinds of XML applications and services.
- Better message handling facilities are integrated into the JSP environment, not coincidentally based on XML and the Simple Object Access Protocol, aka SOAP.
Tag libraries permit collections of custom, XML-like tags to be defined and used in Java servlets constructed to invoke such libraries. In other words, a tag library defines a set of Java classes for the custom JSP actions that the tag library supports. Invoking the tag library imports custom processing and actions into the Java environment so a Java runtime environment like JRun 3.0 will know what to do with such tags as they're recognized. Tag libraries are usually packaged as Java archives in JAR files to make custom tag functions available to developers as they create content, and to Java runtime environments and tools as they encounter and react to such custom tags.
The great thing about JSP and Java servlets is that they run on the server side, and can therefore control their environments to a large extent. This makes it possible to grab and interpret XML-based data on the server, and to transform it into plain-vanilla HTML, XHTML, or other formats (PDF, plain text, rich text files, and so forth) for delivery to Web clients. This helps sidestep the kinds of horrible compatibility issues that dynamic content can cause on the user agent side of a Web or other Internet service connection by keeping custom activities entirely on the server side, where they can be carefully implemented, tested, monitored, and controlled without necessarily being exposed to users.
I find it very interesting that what works for effective delivery of XML data in general works equally well as a technique for combining Java and XML to supports all kinds of powerful, dynamic applications and services. For more information on this great topic, please consult:
- Sun's Java Server Pages home (http://java.sun.com/products/jsp/)
- Westy Rockwell's article on "JSP Tag Libraries" at www.informit.com (search on JSP or the entire title for this and lots of other useful references)
- Visit jakarta.apache.org to examine a substantial collection of custom JSP tag libraries.
- www.orionserver.com offers a nice JSP tutorial and another good collection of JSP tag libraries as well.
- Bill Brogden's excellent book Java Developer's Guide to Servlets and JSP does a nice job of introducing servlets and JSP, and covering tag libraries as well.
Have questions, comments, or feedback about this or other XML-related topics? Please e-mail me at firstname.lastname@example.org; I'm always glad to hear from my readers!
Ed Tittel is a principal at LANWrights, Inc., a wholly owned subsidiary of LeapIt.com. LANWrights offers training, writing, and consulting services on Internet, networking, and Web topics (including XML and XHTML), plus various IT certifications (Microsoft, Sun/Java, and Prosoft/CIW).