First, it is necessary to know the difference between Tomcat and JServ because people use to confuse about them, and some think both of them are the same. Before Tomcat, there was another servlet container called JServ and was Servlet 2.0 compliant. It worked in conjunction with apache using a module called mod_jserv for process communication between them.
Tomcat is a new independent Servlet 2.2 compliant container and it does not have any relationship with JServ, but some code that was reused specially with the JServ's Apache adapter called mod_jserv.
The problem was that mod_jserv was too complex due to the legacy code that was brought with it when it was ported from the Apache/JServ. Then it was logical that a new version of the module had to be written. Another important problem was that mod_jserv supported only Apache, while mod_jk supports many web servers through a compatibility layer named the "jk" library. Supporting two different modes of work became problematic in terms of support, documentation and bug fixes. Something regarding to security has to do with SSL, mod_jserv wasn't able to identify in a reliable way if a request was made by HTTP or HTTPS protocol, but mod_jk uses a protocol called ajp13 that allows it to identify them. In few words, what Tomcat needs to connect with Apache is an "agent" that resides in the address space of the Web Server and sends him servlet requests. This is the web server plugin, and this is mod_jk. The redirector usually comes in the shape of a DLL/shared object module that you should plug into the web server. In this case it is called mod_jk.so (for Unix) and mod_jk.dll (for Windows).
To understand what ajp12 and ajp13 are, first we need to know what they were made for. Whenever you need to have a servlet executed, you will need a worker, that is, a Tomcat instance to do it on behalf of the web server. The most common example is to have an Apache web server forwarding servlet requests to Tomcat processes. And we can also configure multiple workers to serve servlets requests on behalf of one web server. We are not going to describe the reasons here, but this configuration is frequently used.
According to the above paragraph, we may identify four different kinds of workers:
So, it is clear now that ajp12 and ajp13 are both TCP/IP based protocols that communicate the Apache server process with the Tomcat workers. In the file worker.properties you can define for each ajp12 worker, a name, a port in which it will listen the requests and a host where it will be executed.
The ajp12 typed workers forward requests to out-of-process Tomcat workers using the ajpv12 protocol over TCP/IP sockets and so does the ajp13 typed workers The main difference between ajpv12 and ajpv13 are that: