1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta NAME="Author" CONTENT="Stefano Mazzocchi">
<title>Apache JServ Mode Of Operation</title>
</head>
<body BGCOLOR="#FFFFFF">
<p align="center"><a href="http://java.apache.org/" target="_top"><img SRC="images/java-apache-project.gif" BORDER="0" WIDTH="609"
HEIGHT="100" ALT="The Java Apache Project"></a></p>
<h1 align="center">Apache JServ Mode of Operation </h1>
<h3>Abstract</h3>
<blockquote>
<p>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.</p>
</blockquote>
<h3>Glossary</h3>
<ul>
<li><i>Client</i><br>
The Apache Web Server (AWS) process/thread becomes the client in the context of this
document because it initiates the request and waits for the response.</li>
<li><i>Server</i><br>
The Apache JServ Servlet Engine (AJ) performs the server function in the context of the
this document.</li>
<li><i>Connection</i><br>
A finite-duration link between client and server, upon which all transmissions occur. This
can theoretically be over any reliable ordered-stream transport but is expected to usually
be delivered over a TCP-based socket.</li>
<li><i>Apache JServ Protocol (AJP)</i><br>
The protocol used on the connection to handle communication between client and server (see
the <a HREF="protocol/AJPv11.html">specification</a> for more detailed info)</li>
<li><i>Request</i><br>
The full process of request handling, started by the client and terminated by the server.</li>
<li><i>Servlet</i><br>
The compiled (.class) version of the servlet</li>
<li><i>Servlet Full Name</i><br>
The full dot-format class name of the servlet (without the .class extension)</li>
<li><i>Servlet Repository</i><br>
A directory or archive where some servlets reside. A repository may contain more java
packages.</li>
<li><i>Servlet Zone</i><br>
A set of servlet repositories that share common configuration parameters. Servlets with
same full name are not allowed in the same zone, but they are allowed if they are
contained by different servlet zones.</li>
</ul>
<h3>Sides</h3>
<blockquote>
<p>AJ is composed by two sides: <i>client side</i> and <i>server side</i>. They are also
referred to as <i>C side </i>and <i>Java side</i> when more precise definition may
generate misunderstandings. </p>
<p>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.</p>
</blockquote>
<h3>Client Side</h3>
<blockquote>
<p>Let us suppose that we have these web server configurations (and others that are not
important in this context): </p>
<blockquote>
<tt><p>ServerName java.apache.org <br>
ApJServMount /servlets ajpv11://localhost:8007/root <br>
ApJServMount /servlets/admin ajpv11://jserv.apache.org:9009/admin <br>
ApJServAction .jhtml /org.apache.jserv.servlets.JServSSI </tt></p>
</blockquote>
<p>Now we analyze the behavior of different URLs requested to the web server: <ul>
<li><tt>http://java.apache.org/servlets/HelloWorldServlet</tt><br>
This URL gets parsed by the web server and passed to mod_jserv, that opens a connection to
localhost on port 8007 using AJP version 1.1 (that currently is the only one supported,
but other versions of the protocol will be implemented in the future), authenticates the
connection, requests the servlet <tt>HelloWorldServlet</tt> on servlet zone <tt>root</tt>
and waits for a response. When the response arrives, it is encapsulated with the right
http headers (based on web server information and response information) and sent to the
http client. </li>
<li><tt>http://java.apache.org/servlets/admin/HelloWorldServlet</tt><br>
This URL is passed to mod_jserv but the connection is now open on port 9009 of a host
named jserv.apache.org, using AJP version 1.1 and following the above path. </li>
<li><tt>http://java.apache.org/servlets/admin.HelloWorldServlet</tt><br>
This URL is exactly equivalent to the one above. </li>
<li><tt>http://java.apache.org/servlets/apache/HelloWorldServlet</tt><br>
This URL follows the same path as the one above, but the servlet requested is now <tt>apache.HelloWorldServlet</tt>,
since directories are dot-formatted by the module if not recognized as mount points. </li>
<li><tt>http://java.apache.org/servlets/admin.HelloWorldServlet.class</tt><br>
This URL looks for a servlet with full name admin.HelloWorldServlet.class, so that the
name of the source file should have been class.java. This is why .class extension should
be removed from the servlet URL requested. </li>
<li><tt>http://java.apache.org/apache/HelloWorld.jhtml</tt><br>
This URL is passed to the .jhtml handler that actually is a servlet. So it is passed again
to mod_jserv that requests the servlet org.apache.jserv.servlets.JServSSI on the
protocol://host:port/zone defined for that mount point. Note that this class is always
found by the servlet engine class loader because it resides on the class path (or, at
least, it should). </li>
</ul>
<p>For deeper understandings of the request/response process, please, refer to the <a
HREF="protocol/AJPv11.html">protocol specifications</a> for more details.</p>
</blockquote>
<h3>Server Side</h3>
<blockquote>
<p>When AJ is started (either automatically or manually), a .properties file (usually
named jserv.properties) 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. </p>
<p>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. </p>
<p>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 <a
HREF="protocol/AJPv11.html#auth">authentication</a> 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. </p>
<p>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. </p>
<p>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.</p>
</blockquote>
<p align="center"><font SIZE="-1">Copyright (c) 1997-99 <a HREF="http://java.apache.org/"
target="_top">The Java Apache Project</a>.<br>
$Id: operation.html,v 1.10 1999/06/09 05:21:22 jonbolt Exp $<br>
All rights reserved.</font></p>
</body>
</html>
|