The Java Apache Project

Apache JServ Mode of Operation


This document describes the way Apache JServ works and it is intended to give detailed information on its mode of operation to quickly bring new developers up to speed. It may give nice information for power users looking for a deeper knowledge for better configuration and fine tuning.



AJ is composed by two sides: client side and server side. They are also referred to as C side and Java side when more precise definition may generate misunderstandings.

Client side is responsible of making requests to the server side and waiting for a response, while server side handles the client requests, executes the requested servlets and sends back the generated response.

Client Side

Let us suppose that we have these web server configurations (and others that are not important in this context):

ApJServMount /servlets ajpv11://localhost:8007/root
ApJServMount /servlets/admin ajpv11://
ApJServAction .jhtml /org.apache.jserv.servlets.JServSSI

Now we analyze the behavior of different URLs requested to the web server:

For deeper understandings of the request/response process, please, refer to the protocol specifications for more details.

Server Side

When AJ is started (either automatically or manually), a .properties file (usually named is passed to the org.apache.jserv.JServ class as a command line parameter. This file specifies the configuration parameters needed by AJ to start. They include the port, the servlet zones with their configuration files, and security parameters. Also, a fine grain tracing capability is included for both debugging and logging purposes.

After parsing these configurations, servlet zones are loaded constructing an org.apache.jserv.JServServletManager class for each servlet zone, and the server bounds to the configured port, listening for connections.

When a connection is requested to its port, AJ filters the incoming connection closing it if it does not come from an allowed IP address. This is used against denial of service attacks. If the address is allowed, the connection is authenticated (see authentication on AJPv1.1). If authentication is successful, a new org.apache.jserv.JServConnection is constructed to handle the request process and, since it extends Runnable, it is passed to a thread for multithreading serving behavior. This allows AJ to the able to handle many concurrent simultaneous requests.

The JServConnection class receives the request parameters, then calls the right JServServletManager (specified by the request servlet zone) and obtains the requested servlet. Then, it sets up the environment for execution and calls the servlet's service() method. JServConnection, together with JServContext and JServSession, provide all the hooks to the Servlet APIs methods needed by the servlet to execute. JServConnection also encapsulates servlet input and output streams.

When servlet service() method is over and all output data has been passed to the client, JServConnection closes the socket connection, indicating the termination of the request process. Returning from its run() method causes both the thread and the class itself to be garbage collectable.

Copyright (c) 1997-99 The Java Apache Project.
$Id: operation.html,v 1.10 1999/06/09 05:21:22 jonbolt Exp $
All rights reserved.