Application Server Architectures

Application Servers
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

It's hard to be an iSeries programmer these days. Even if you want to move out of the green-screen paradigm, there are a number of things holding you back. Today's topic, Web application architectures, is a microcosmic example of the whole issue.

It's clear that we need a Web interface. A few fervent but somewhat fringe voices are demanding a "native GUI" for the iSeries, but that battle is long lost. Considering the fact that UNIX doesn't have a "native GUI" (real UNIX programmers use the command line), it's pretty clear that a combination of browser-based and rich-client interfaces marks the future of all server-based programming, whether it's the iSeries' midrange-centric style or Microsoft's server-farm style.

And since we need Web applications, we need a Web application server. And since we need a Web application server, we need a Web application server architecture. And this is where things generally come to a screeching halt. Why? Because there are at least three major competing architectures, with a number of new ones (or variants) on the horizon. Not only that, but the issues that favor one approach from a tactical standpoint often favor a different direction strategically.

In this column, I'll present the "Big Three" of Web application architectures and the various sub-genres:

  • Java-based Web application servers—Non-certified and J2EE certified
  • Common Gateway Interface (CGI)—RPG and other languages
  • Microsoft .NET
  • Other options

Java-Based Web Application Architectures

Let's start off with a disclaimer: Java-based servers and especially J2EE-compliant servers are my personal favorites. By the end of this article, you may or may not agree with me, but I think it's only fair to make my bias clear from the beginning.

Let's also get some terminology issues out of the way. Now that the whole world finally has its head around the term "J2EE" to refer to Sun's enterprise-level Java platform, Sun has changed the naming conventions again. The "2" is gone, as is the Java 1.x numbering scheme. The current release of Java (Tiger) is Java 5, and the editions are Java SE (Standard Edition), Java EE (Enterprise Edition) and Java ME (Micro Edition). To fully name a Java platform, you specify the edition and version, so the latest and greatest enterprise platform is now Java EE 5. The Mustang release currently in the works will be Java 6, so its enterprise platform will be Java EE 6. Got it? Good!

On to the architectures. All Java Web servers work the same way: They use servlets, which may or may not have persistent connections to the browser. With a persistent connection, the application can basically become stateful and store information about the current browser session in memory without having to constantly either load it from disk or from a cookie. While there are a number of technical details with this concept, it is far more efficient for running business applications than the traditional stateless approach of standard HTTP communications. Note also that while JavaServer Pages (JSPs) seem to be more like "super HTML pages" than Java programs, JSPs are converted to servlets at runtime and thus have all the benefits (and drawbacks) of the Java Web application architecture.

There are currently two distinct flavors of Java Web servers: those that are Java EE-certified and those that are not. And within the Java-certified versions, there are levels of certification. For example, the vast majority of application servers are J2EE 1.4-certified. The only server I know of that is Java EE 5-certified is the open source GlassFish server. Since a certified server is really a superset of a non-certified server, let's start with the non-certified Java Web application servers.

Non-Certified Java Web Application Servers

I currently know of three of these: Tomcat, Jetty, and Resin. You've probably heard of Tomcat: It's the free application server available from the Apache Software Foundation. Tomcat has been around for awhile and for a short time it was even "sort of" supported by IBM on the iSeries. Jetty is a small-footprint server that is often embedded in completely portable applications and is nearly as fast as Tomcat. Resin is a bit of a niche player. It gets mixed reviews on benchmarks but is generally a more "nerd-worthy" architecture: Generated JSP code is more elegant and faster but at the cost of not being 100% compatible with the J2EE specifications.

Java EE Certified

What does "Java EE certified" mean? It means among other things that a whole range of specifications has been met, which includes a wide variety of "optional" Java packages. While I'm no expert, it's clear to me that the amount of work already done for Java EE developers is significant.

Most application servers are currently certified for the J2EE 1.4 platform. These include packages like IBM WebSphere, JBoss, BEA WebLogic, ObjectWeb JOnAs, Oracle 10g, and Apache Geronimo. A very interesting recent development is that IBM has just released a completely free version of WebSphere called WebSphere Community Edition that is based on Apache Geronimo!

There is only one Java EE 5-certified server that I know of, GlassFish. Here's a list of the packages that must be available for a Web application server to be Java EE 5-certified:

  • Common Annotations 1.0
  • Connector 1.5
  • EJB 3.0
  • JACC 1.1
  • JAF 1.1
  • Java EE Management 1.1
  • Java Persistence 1.0
  • JavaMail 1.4
  • JAXB 2.0
  • JAXR 1.0
  • JAX-RPC 1.1
  • JAX-WS 2.0
  • JMS 1.1
  • JSF 1.2
  • JSP 2.1
  • JSP Debugging 1.0
  • JSTL 1.2
  • JTA 1.1
  • SAAJ 1.3
  • Servlet 2.5
  • StAX 1.0
  • Web Services 1.2
  • Web Services Metadata 2.0

While some of these—Servlet, JSP, JSF—are obviously required by a JSP container, others are really powerful pieces that give the Java EE programmer a lot of pre-written code to use. And these are not snippets that you download off the Internet and hope work in your application; these are rigorously defined APIs. A couple that jump out immediately are JavaMail and the various JAX APIs. JavaMail provides a robust but easy-to-use mail interface, while the various flavors of JAX provide very specific extensions to basic XML handling procedures. JAXB is a way to bind XML and Java objects, which makes it very easy to write good, readable Java code to communicate with XML documents (such as for Web Services).

The big issue here is that Java EE certification provides a wealth of ready-to-use APIs that simplify the job of Web application development.

Common Gateway Interface (CGI) Servers

This is something of a misnomer; a CGI server isn't really a server. It's a way to allow HTTP requests to be routed through the HTTP server and to a specific program. CGI predates the servlet model and is a bit more basic. In general, every time the HTTP server receives a CGI request, a new process is "spawned" and the request is passed to it. Data is generally passed in via "pipes," which are special mechanisms designed to allow a stream of data to be sent from one process to another.


While primarily a UNIX concept, this process and pipes architecture has been replicated on Windows and even on the iSeries, although the overhead associated with creating new processes for each request is quite expensive, especially if you are using a non-multi-threaded language, such as RPG. Without extensive modification of this process, the overhead for multiple calls is quite high. Note that the use of AJAX, which essentially breaks up a single Web page into multiple small calls, only exacerbates the problem.

There is an alternative, by the way. The free software package called FastCGI is designed to mitigate the overhead issue somewhat by creating a "pool" of jobs that will process requests in a round-robin fashion and then go quiescent while waiting for another request. This means the startup penalty is incurred only once. From all accounts, this approach works quite well, although it's yet another failure point you've added to your system. I'm not sure how support works with the FastCGI product.

Script Languages

Another entire set of CGI approaches uses script languages. These include Perl, PHP, Python, and Ruby. Each of these languages requires some sort of native interpreter on the host system. A reasonable analogy for these languages is to think of them as "BASIC-like." They allow you to sort of "feel" your way through the design process, adding bits and pieces as you see fit, without requiring much in the way of a rigorous up-front design. Thus, they're eminently well-suited for things like proofs of concept or rapid prototypes. However, these languages are not particularly appropriate for large-scale development and maintenance unless you put a lot of procedures in place. I once talked to a Python developer and I mentioned that the primary tool I used in development was a text-scanning utility, and he laughed and agreed. That's because most scripting language applications consist of dozens and dozens (if not hundreds or thousands) of small script files. And unlike Java, which is a strongly typed language and has a very specific methodology for grouping, organizing, and inspecting code, most script languages are simply text-based. If you want to find the code that uses a given procedure, scan all of your source with a text scanner.

That issue aside, many of these script languages (Ruby and Python in particular) have large pre-written libraries of code that can be used to develop Web applications. I've heard it said that it takes one line of code to write an HTTP server in Python. I'm not sure of that claim, but I can't categorically deny the possibility. It just means that someone has built a very easy-to-use HTTP server library with a lot of defaults built in.

Other Compiled Languages

I should note at this point that any compiled language can conceivably be used as a CGI language. In fact, lots of C code has been used over the years on UNIX machines. Since you have both C and C++ compilers available on the iSeries, there's nothing stopping you from using them. You could even use COBOL if you're so inclined.

Microsoft .NET

It's a nice day, a nice time of year, a nice holiday (happy belated Fourth of July), and I refuse to get all worked up. That being the case, I'm not going to spend a ton of time on the .NET option. It's sufficient to say that .NET is the Microsoft solution. If you want to go all Microsoft all the time, then by all means use .NET. But don't be blinded by so-called compatibility options: I've heard about Mono, and I've heard about IKVM, and neither of them is completely supported by anybody, so entrusting your mission-critical systems to either one is a risk that you will have to justify.

If you do choose the Microsoft approach, .NET allows you to invoke any of the CLR-capable languages in response to Web interactions from the user. I haven't taken a lot of time to test this particular approach; with the constant slipping of both Office and Vista, it seems a little dangerous to me to count on viable software from Microsoft anytime in the near future. Of course, I'm a Java EE bigot, so what would you expect me to say? Perhaps someone with more time using these tools can respond in the forums and give you a more informed opinion.

Other Options

There are a few other options out there. I mentioned Python awhile back; well, Python has an entire Web-application-serving environment that is packed with features and designed from the ground up to build Web applications. The tools are Plone and Zope, and in literally hours, I had an entire Web site built on this platform. The problem is that at the time I tried it, the iSeries didn't support a recent enough version of Python, but I'm thinking about trying it again in the near future.

I should also mention the various macro languages, which include the granddaddy of them all, ColdFusion, as well as one near and dear to many iSeries developers, Net.Data (most definitely not to be confused with anything .NET). With these languages, you embed tags into your HTML, which are in turn used to run programs that access data and perform business logic, ultimately returning data back to the Web page. The problem with this design is the fact that it is diametrically opposed to what we currently recognize as the "optimal" approach of separating model, view, and controller (MVC). With macro languages, the business logic is often embedded directly into the HTML, making for some really difficult-to-maintain applications.

The Verdict

If you simply refuse to have anything to do with Java, then your choices are pretty straightforward: RPG or scripts. It's a little strange to me that you would be willing to learn a completely foreign language like Ruby but not Java, especially since you need to understand basic Java syntax to add JavaScript to your HTML pages and JavaScript is a necessity in business applications. So to me, if you don't go Java, go RPG. IBM's CGIDEV2 is a complete package that will help you develop CGI-based business applications, and there are also some commercial packages out there and people willing to teach them to you for a fee.

On the other hand, if you want to go the Java route, I'd tell you to go with something supported, like WebSphere. You could skip WebSphere and go with something like Tomcat or JBoss or even Resin, but be careful to keep your code vanilla enough to switch between servers easily, because the biggest problem with this decision is not application design but server lock-in. But if you code basic JSP Model II architecture and avoid implementation-specific techniques, you ought to be good to go on any Java-based server.

Note that JSPs were originally intended as the Java response to this architecture, but because the non-MVC nature was so counter-productive, a new approach (JSP Model II) evolved in which a servlet builds Beans that are sent to a JSP for display. As I mention often in my seminars, this is really the 5250 programming model, only inside a browser. And that is perhaps the final reason that I love JSP Model II and the Java EE architecture: We've been proving that this architecture works for 30 years now. We just added a new terminal type: the browser.

Joe Pluta is the founder and chief architect of Pluta Brothers Design, Inc. and has been extending the IBM midrange since the days of the IBM System/3. Joe uses WebSphere extensively, especially as the base for PSC/400, the only product that can move your legacy systems to the Web using simple green-screen commands. He has written several books including E-Deployment: The Fastest Path to the Web, Eclipse: Step by Step, and WDSC: Step by Step. Joe performs onsite mentoring and speaks at user groups around the country. You can reach him at This email address is being protected from spambots. You need JavaScript enabled to view it..