Home

JSP and Beyond

a pragmatic primer on building web-based solutions with Java technologies


Application Server Architecture

In order to run your dynamic web applications using JSP, you will need a Java Application Server or what are often times referred to as a “container”. When a JSP page is requested, it is this container that will ultimately deal with processing the request.

It is important to understand at a high level how the container processes a request from a user, as this interaction underlies all JSP operations. The diagram below illustrates how an application server deals with these requests for dynamic content.

1. The client (i.e. user) makes a request for an item on the server (JSP, JPG, GIF, etc.).
2. The web container checks to see if the content has been requested before. If so the container will serve the content from an existing class file which is the result of a previously requested JSP (step B). If the content has not been requested before the container will build a class file and then process the request by executing the class file (step A).
3. The content is then served back to the HTTP server to be sent back to the client.

Regardless of the application server that is used to run your Java application, it will always process the request in the same nature. For our purposes we will initially work with a free container like Tomcat.

So… if that is Tomcat, what is this Apache Tomcat thing that I am hearing about? That is an excellent question!

Although at first a bit confusing, application servers have historically combined with an HTTP server for maximum performance in a slightly different manner than the sample above, which used a single application server that acts as both the java application server and HTTP server.

This has been done because the Apache HTTP server is designed to serve static content (HTML, GIF, JPG, CSS, JS, etc.) at a high rate under a high load. While Tomcat, the Java Application Server, by itself is capable of serving this content as well, it is not as optimized or configurable as an Apache HTTP server for this task. This is why it is common to hear about “Apache Tomcat”. The process of using a separate HTTP server and Java Application Server to handle an HTTP request are outlined below.

1. The client (i.e. user) makes a request for an item on the server (JSP, JPG, GIF, etc.).
2. The HTTP server checks to see if the request is a static item (JPG, GIF, etc.) or an item that needs further processing (JSP).
3. The web container checks to see if the content has been requested before. If so the container will serve the content from an existing class file. If the content has not been requested before the container will build a class file and then process the request by executing the class file.
4. The dynamic content is then served back to the HTTP server to be sent back to the client.