Chapter 9. Java Programming with XML and SQL

In which the TLAs come out in full force.

So far in this book, we've looked at XML and relational databases and some strategies for combining the two to create powerful applications. In Chapter 8, we looked at ways to build specific database structures in a real-world database. In this chapter, I discuss building your application code in Java with a J2EE-type application server.

Produced by Sun, the J2EE (Java 2 Enterprise Edition) specification gives application server vendors a baseline for how their software should behave in order to be J2EE-compliant. This means that a J2EE application should work in any J2EE-compliant application server.

I'm a big fan of server-side Java. which I've been using since 1996. At that time, most people looked at you funny when you said “server side Java.” Java was thought of as a language for building funny little animations on Web pages. That was one way Sun was marketing it, but I saw in Java an opportunity to build on the server side simple Web applications that would be a perfect replacement for all the crusty Perl scripts we had been writing in the small Web consulting business I was involved with. Why? Java is an object-oriented language; it is simple to use and to get started in (especially compared with C++), and it comes with built-in APIs to support functions (such as HTTP requests, string parsing, URL management, and database connections) often needed when building Web applications. Today, the J2EE standard, which evolved from those humble beginnings in 1996, is one of the most widely used application environments for Web applications, and most people have forgotten about the Web page animations that started it all.

The J2EE specification basically consists of Enterprise Java Beans (EJBs—self-contained objects that conform to a specific standard) that interact with back-end data sources, servlets (the server equivalent of a Java applet—a Java program that runs on the server side and responds to HTTP requests, possibly calling out to functionality in deeper level EJBs in the process), and Java Server Pages, abbreviated JSP, (which essentially are a specialized form of servlet and Sun's answer to Microsoft's Active Server Pages) on the front end that interact with client programs over HTTP.

The rest of the J2EE specification consists of a set of class libraries that allow these servlets and EJBs to perform specific functions (such as the Java DataBase Connectivity layer—JDBC—that allows for connection to back-end data sources or the JavaMail API that provides functions for dealing with e-mail messages programmatically). The idea is that the business logic of your application should exist in the EJBs and all client interaction should happen at the servlet layer. A basic diagram of how these layers interact is shown in Figure 9-1.

Figure 9-1. The J2EE application framework


You could write an entire book on Java and XML, but someone already has: XML and Java: Developing Web Applications by Hiroshi Maruyama, Kent Tamura, and Naohiko Uramoto (1999). This chapter provides an overview of some of the features of the J2EE framework and the JAXP (Java API for XML Processing) that apply mostly to building applications with XML and SQL.

Much of the material presented in this chapter will make the most sense to a developer who's already familiar with the Java language—this isn't a primer on Java. If you're not planning to use Java, I suggest you at least read the following sidebar on the SAX and DOM parsers (Parsers: SAX versus DOM). You may want to read through the brief examples on using SAX and DOM as well. For those of you planning on developing with Java, this chapter will be more relevant.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.214.215