org.mortbay.http.handler

Class ForwardHandler

Implemented Interfaces:
HttpHandler, LifeCycle, Serializable

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)

Constructor Summary

ForwardHandler()
Constructor.
ForwardHandler(String rootForward)
Constructor.

Method Summary

void
addForward(String pathSpecInContext, String newPath)
Add a forward mapping.
void
handle(String pathInContext, 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(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

Constructor Details

ForwardHandler

public ForwardHandler()
Constructor.

ForwardHandler

public ForwardHandler(String rootForward)
Constructor.
Parameters:
rootForward -

Method Details

addForward

public void addForward(String pathSpecInContext,
                       String newPath)
Add a forward mapping.
Parameters:
pathSpecInContext - The path to forward from
newPath - The path to forward to.

handle

public void handle(String pathInContext,
                   String pathParams,
                   HttpRequest request,
                   HttpResponse response)
            throws HttpException,
                   IOException
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.
Specified by:
handle in interface HttpHandler
Parameters:
pathInContext - The context path
pathParams - Path parameters such as encoded Session ID
request - The HttpRequest request
response - The HttpResponse response

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 -

setRootForward

public void setRootForward(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.

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