Skip to content
java implementation of an ajp13 protocol client, allowing to send requests to a servlet container using this protocol.
Java Python Shell
Branch: master
Clone or download
Latest commit 6e34eab Oct 25, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
scripts instructions for deployement on maven central repos May 24, 2017
src assume length is 2 bytes when reading strings Oct 25, 2019
.travis.yml java 9 Jul 24, 2019
LICENSE comply with sonatype's OSSRH package naming policy Oct 9, 2014 reorganized badges Oct 25, 2019
pom.xml fix: pom.xml to reduce vulnerabilities Oct 25, 2019

java client library for the Apache JServ Protocol 1.3

This is a java implementation of an ajp13 client, allowing to send requests to a servlet container using this protocol.

Licensed under the Apache License, Version 2.0 (see LICENSE)

Build Status Maven Central Coverage Status Known Vulnerabilities

Commits Code statistics

Simple Usecases :

  • Making a cPing request (checks server availability)
	import com.github.jrialland.ajpclient.pool.Channels;
	import com.github.jrialland.ajpclient.CPing;


	//get a tcp connection
	final Channel channel = Channels.connect("localhost", 8009);
	//will try a cping/cpong exchange on the opened tcp connection
	boolean success = new CPing(2, TimeUnit.SECONDS).execute(channel);
  //                                                .execute("localhost", 8009);	
  • Making a forward request (serves web content)
	import com.github.jrialland.ajpclient.pool.Channels;
	import com.github.jrialland.ajpclient.Forward;

	//send a forward request
	new Forward(ajpRequest, ajpResponse).execute("localhost", 8009);
  • Using a client sockets pool :

Socket pools handle the creation and destruction of multiple connections automatically.

	import com.github.jrialland.ajpclient.pool.Channels;
	import com.github.jrialland.ajpclient.Forward;
	Channels.getPool("localhost", 8009).execute(new Forward(ajpRequest, ajpResponse));

Will use a socket channel picked from a pool, allowing the reuse of sockets among request.

  • The library can be used directly in a servlet container in order to forward requests to another servlet container :
	import javax.servlet.http.HttpServletRequest;
	import javax.servlet.http.HttpServletResponse;
	import com.github.jrialland.ajpclient.servlet.AjpServletProxy;
	HttpServletRequest request = ...
	HttpServetResponse response = ...
	//forward an servlet request to another server
	AjpServletProxy.forHost("localhost", 8009).forward(request, response);

AJP header size limit

The protocol does not allow request headers to be greater that 8K, which is ok most of the time. to overcome this limit, at least with tomcat 5.5.21+ and Tomcat 6.0.1+

  1. add the packetSize attribute to the connector's declaration
    <Connector port="8009" protocol="AJP/1.3"
               redirectPort="8443" ></Connector>
  1. Change the limit in Apache Server configuration :
ProxyIOBufferSize 19000 
LimitRequestFieldsize 18000
You can’t perform that action at this time.