org.mortbay.http.handler
Class ForwardHandler

java.lang.Object
  extended by org.mortbay.http.handler.AbstractHttpHandler
      extended by org.mortbay.http.handler.ForwardHandler
All Implemented Interfaces:
java.io.Serializable, HttpHandler, LifeCycle

public class ForwardHandler
extends AbstractHttpHandler

Forward Request Handler. Forwards a request to a new URI. Experimental - use with caution.

Version:
$Revision: 1.16 $
Author:
Greg Wilkins (gregw)
See Also:
Serialized Form

Constructor Summary
ForwardHandler()
          Constructor.
ForwardHandler(java.lang.String rootForward)
          Constructor.
 
Method Summary
 void addForward(java.lang.String pathSpecInContext, java.lang.String newPath)
          Add a forward mapping.
 void handle(java.lang.String pathInContext, java.lang.String pathParams, HttpRequest request, HttpResponse response)
          Handle a request.
 void setHandleQueries(boolean b)
          Set the Handler up to cope with forwards to paths that contain query elements (e.g.
 void setRootForward(java.lang.String newPath)
          Add a forward mapping for root path.
 
Methods inherited from class org.mortbay.http.handler.AbstractHttpHandler
getHttpContext, getName, handleTrace, initialize, isStarted, setName, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForwardHandler

public ForwardHandler()
Constructor.


ForwardHandler

public ForwardHandler(java.lang.String rootForward)
Constructor.

Parameters:
rootForward -
Method Detail

addForward

public void addForward(java.lang.String pathSpecInContext,
                       java.lang.String newPath)
Add a forward mapping.

Parameters:
pathSpecInContext - The path to forward from
newPath - The path to forward to.

setRootForward

public void setRootForward(java.lang.String newPath)
Add a forward mapping for root path. This allows a forward for exactly / which is the default path in a pathSpec.

Parameters:
newPath - The path to forward to.

setHandleQueries

public void setHandleQueries(boolean b)
Set the Handler up to cope with forwards to paths that contain query elements (e.g. "/blah"->"/foo?a=b").

Parameters:
b -

handle

public void handle(java.lang.String pathInContext,
                   java.lang.String pathParams,
                   HttpRequest request,
                   HttpResponse response)
            throws HttpException,
                   java.io.IOException
Description copied from interface: HttpHandler
Handle a request. Note that Handlers are tried in order until one has handled the request. i.e. until request.isHandled() returns true. In broad terms this means, either a response has been commited or request.setHandled(true) has been called.

Parameters:
pathInContext - The context path
pathParams - Path parameters such as encoded Session ID
request - The HttpRequest request
response - The HttpResponse response
Throws:
HttpException
java.io.IOException


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.