Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.ajp
Class Ajp13

    java.lang.Object
      org.apache.ajp.Ajp13

public class Ajp13
extends java.lang.Object

Represents a single, persistent connection between the web server and the servlet container. Uses the Apache JServ Protocol version 1.3 for communication. Because this protocal does not multiplex requests, this connection can only be associated with a single request-handling cycle at a time.

This class contains knowledge about how an individual packet is laid out (via the `Ajp13Packet` class), and also about the stages of communicaton between the server and the servlet container. It translates from Tomcat's internal servlet support methods (e.g. doWrite) to the correct packets to send to the web server.

Author:
  Dan Milstein [danmil@shore.net], Keith Wannamaker [Keith@Wannamaker.org], Kevin Seguin [seguin@apache.org], Henri Gomez [hgomez@apache.org], Costin Manolache
See Also:
  `Ajp13Interceptor`

Field Summary
`protected int` | `debug`
`static int` | `H_SIZE`
`static int` | `JK_AJP13_BAD_BODY`
`static int` | `JK_AJP13_BAD_HEADER`
`static int` | `JK_AJP13_COMM_BROKEN`
`static int` | `JK_AJP13_COMM_CLOSED`
`static int` | `JK_AJP13_INCOMPLETE_BODY`
`static int` | `JK_AJP13_NO_HEADER`
`static int` | `MAX_PACKET_SIZE`
`static int` | `MAX_READ_SIZE`
`static int` | `MAX_SEND_SIZE`
`Ajp13Packet` | `outBuf`
`RequestHandler` | `reqHandler`

Constructor Summary
`Ajp13()`
`Ajp13(RequestHandler reqHandler)`

Method Summary
`int` | `available()` Deprecated. -- Will use reqHandler, make sure nobody else calls this
`void` | `beginSendHeaders(int status, java.lang.String statusMessage, int numHeaders)`
`void` | `close()` Close the socket connection to the web server.
`int` | `doRead()`
`int` | `doRead(byte[] b, int off, int len)`
`void` | `doWrite(byte[] b, int off, int len)`
`void` | `endSendHeaders()`
`void` | `finish()`
`java.lang.String` | `getSecret()`
`int` | `handleMessage(int type, Ajp13Packet hBuf, BaseRequest req)` Override for ajp14, temporary
`void` | `initBuf()` Will be overriden
`boolean` | `isLogged()`
`int` | `receive(Ajp13Packet msg)` Read in a packet from the web server and store it in the passed-in `Ajp13Packet` object.
`int` | `receiveNextRequest(BaseRequest req)` Read a new packet from the web server and decode it.
`void` | `recycle()`
`int` | `registerMessageType(int id, java.lang.String name, AjpHandler h, java.lang.String[] sig)`
`void` | `send(Ajp13Packet msg)` Send a packet to the web server.
`void` | `sendHeader(java.lang.String name, java.lang.String value)`
`void` | `sendHeaders(int status, MimeHeaders headers)`
`void` | `sendHeaders(int status, java.lang.String statusMessage, MimeHeaders headers)`
`void` | `setBackward(boolean b)` Backward compat mode, no login needed
`void` | `setDebug(int debug)`
`void` | `setLogger(Logger l)`
`void` | `setSecret(java.lang.String s)`
`void` | `setSocket(java.net.Socket socket)` Associate an open socket with this instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MAX_PACKET_SIZE

    public static final int MAX_PACKET_SIZE

See Also:
  Constant Field Values

### H_SIZE

    public static final int H_SIZE

See Also:
  Constant Field Values

### MAX_READ_SIZE

    public static final int MAX_READ_SIZE

See Also:
  Constant Field Values

### MAX_SEND_SIZE

    public static final int MAX_SEND_SIZE

See Also:
  Constant Field Values

### JK_AJP13_BAD_HEADER

    public static final int JK_AJP13_BAD_HEADER

See Also:
  Constant Field Values

### JK_AJP13_NO_HEADER

    public static final int JK_AJP13_NO_HEADER

See Also:
  Constant Field Values

### JK_AJP13_COMM_CLOSED

    public static final int JK_AJP13_COMM_CLOSED

See Also:
  Constant Field Values

### JK_AJP13_COMM_BROKEN

    public static final int JK_AJP13_COMM_BROKEN

See Also:
  Constant Field Values

### JK_AJP13_BAD_BODY

    public static final int JK_AJP13_BAD_BODY

See Also:
  Constant Field Values

### JK_AJP13_INCOMPLETE_BODY

    public static final int JK_AJP13_INCOMPLETE_BODY

See Also:
  Constant Field Values

### outBuf

    public Ajp13Packet outBuf

### reqHandler

    public RequestHandler reqHandler

### debug

    protected int debug

Constructor Detail

### Ajp13

    public Ajp13()

### Ajp13

    public Ajp13(RequestHandler reqHandler)

Method Detail

### initBuf

    public void initBuf()

  Will be overriden

### recycle

    public void recycle()

### setSocket

    public void setSocket(java.net.Socket socket)
                   throws java.io.IOException

  Associate an open socket with this instance.

  Throws:
    `java.io.IOException`

### setBackward

    public void setBackward(boolean b)

  Backward compat mode, no login needed

### isLogged

    public boolean isLogged()

### setSecret

    public void setSecret(java.lang.String s)

### getSecret

    public java.lang.String getSecret()

### registerMessageType

    public int registerMessageType(int id,
                                   java.lang.String name,
                                   AjpHandler h,
                                   java.lang.String[] sig)

### receiveNextRequest

    public int receiveNextRequest(BaseRequest req)
                           throws java.io.IOException

  Read a new packet from the web server and decode it. If it's a forwarded request, store its properties in the passed-in AjpRequest object.

  Parameters:
    `req` - An empty (newly-recycled) request object.
  Returns:
    200 in case of a successful read of a forwarded request, 500 if there were errors in the reading of the request, and -2 if the server is asking the container to shut itself down.
  Throws:
    `java.io.IOException`

### handleMessage

    public int handleMessage(int type,
                             Ajp13Packet hBuf,
                             BaseRequest req)
                      throws java.io.IOException

  Override for ajp14, temporary

  Throws:
    `java.io.IOException`

### available

    public int available()
                  throws java.io.IOException

  Deprecated. -- Will use reqHandler, make sure nobody else calls this

  Throws:
    `java.io.IOException`

### doRead

    public int doRead()
               throws java.io.IOException

  Throws:
    `java.io.IOException`

### doRead

    public int doRead(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException

  Throws:
    `java.io.IOException`

### beginSendHeaders

    public void beginSendHeaders(int status,
                                 java.lang.String statusMessage,
                                 int numHeaders)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### sendHeader

    public void sendHeader(java.lang.String name,
                           java.lang.String value)
                    throws java.io.IOException

  Throws:
    `java.io.IOException`

### endSendHeaders

    public void endSendHeaders()
                        throws java.io.IOException

  Throws:
    `java.io.IOException`

### sendHeaders

    public void sendHeaders(int status,
                            MimeHeaders headers)
                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### sendHeaders

    public void sendHeaders(int status,
                            java.lang.String statusMessage,
                            MimeHeaders headers)
                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### finish

    public void finish()
                throws java.io.IOException

  Throws:
    `java.io.IOException`

### doWrite

    public void doWrite(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### receive

    public int receive(Ajp13Packet msg)
                throws java.io.IOException

  Read in a packet from the web server and store it in the passed-in `Ajp13Packet` object.

  Parameters:
    `msg` - The object into which to store the incoming packet -- any current contents will be overwritten.
  Returns:
    The number of bytes read on a successful read or -1 if there was an error.
  Throws:
    `java.io.IOException`

### send

    public void send(Ajp13Packet msg)
              throws java.io.IOException

  Send a packet to the web server. Works for any type of message.

  Parameters:
    `msg` - A packet with accumulated data to send to the server -- this method will write out the length in the header.
  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Close the socket connection to the web server. In general, sockets are maintained across many requests, so this will not be called after finish().

  Throws:
    `java.io.IOException`
  See Also:
    `Ajp13Interceptor#processConnection`

### setDebug

    public void setDebug(int debug)

### setLogger

    public void setLogger(Logger l)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.