com.mortbay.HTTP.Handler
Class ForwardHandler

java.lang.Object
  |
  +--com.mortbay.HTTP.Handler.NullHandler
        |
        +--com.mortbay.HTTP.Handler.ForwardHandler

public class ForwardHandler
extends NullHandler

Forward HttpHandler This handler forwards a request onto another HttpServer. It is configured with a PathMap of paths to URL instances. The request is forwarded to the host and port of the URL with the matching part of the request path translated to the path provided in the URL. Forwarding is different to a redirect as the response is still passed through this server and may be filtered or modified is some other fashion.

Proxy HTTP servers are supported.

Notes

ForwardHandler should not be placed after the ParamHandler unless it is known that no form or query content will be forwarded. As ParamHandler moves all form content and cookies to the parameters, these will be duplicated in the query content of the forwarded request.

Version:
$Id: ForwardHandler.java,v 2.7 2000/01/17 15:30:28 gregw Exp $
Author:
Greg Wilkins

Fields inherited from class com.mortbay.HTTP.Handler.NullHandler
httpServer
 
Constructor Summary
ForwardHandler(PathMap forwardMap)
          Construct a ForwardHandler
ForwardHandler(PathMap forwardMap, InetAddrPort proxy)
          Construct a ForwardHandler that uses a HTTP proxy.
ForwardHandler(java.util.Properties properties)
          Construct from properties.
 
Method Summary
 void handle(HttpRequest request, HttpResponse response)
          Handle forward for requests.
 void setProperties(java.util.Properties properties)
          Configure from Properties.
 
Methods inherited from class com.mortbay.HTTP.Handler.NullHandler
destroy, getProperties, servlet, servletNames, setServer, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardHandler

public ForwardHandler(java.util.Properties properties)
               throws java.io.IOException
Construct from properties.
Parameters:
properties - Passed to setProperties

ForwardHandler

public ForwardHandler(PathMap forwardMap)
Construct a ForwardHandler
Parameters:
forwardMap - Maps path to a URL

ForwardHandler

public ForwardHandler(PathMap forwardMap,
                      InetAddrPort proxy)
Construct a ForwardHandler that uses a HTTP proxy.
Parameters:
forwardMap - Maps path to a URL
Method Detail

setProperties

public void setProperties(java.util.Properties properties)
                   throws java.io.IOException
Configure from Properties. Properties are assumed to be in the format of a PropertyTree like:
 ProxyAddrPort        : 0.0.0.0:1234
 FORWARD.name.PATHS   : /pathSpec;/list%
 FORWARD.name.URL     : http:/forward/url
The Proxy address is optional.
Overrides:
setProperties in class NullHandler
Parameters:
properties - Configuration.

handle

public void handle(HttpRequest request,
                   HttpResponse response)
            throws java.io.IOException
Handle forward for requests.
Overrides:
handle in class NullHandler
Tags copied from interface: HttpHandler
Parameters:
request - The HTTP requests to be handled
response - The HTTP response to be used.