public class RewriteHandler
extends org.mortbay.jetty.handler.HandlerWrapper
The RewriteHandler is responsible for managing a list of rules to be applied to requests. Its capabilities are not only limited to url rewrites such as RewritePatternRule or RewriteRegexRule; there is also handling for cookies, headers, redirection, setting status or error codes whenever the rule finds a match.
The rules can be matched by the ff. options: pattern matching of PathMap (class PatternRule), regular expressions (class RegexRule) or certain conditions set (e.g. MsieSslRule - the requests must be in SSL mode). Here are the list of rules:
The rules can be grouped into rule containers (class RuleContainerRule), and will only be applied if the request matches the conditions for their container (e.g., by virtual host name) Here are a list of rule containers:
Constructor and Description |
---|
RewriteHandler() |
Modifier and Type | Method and Description |
---|---|
void |
addRewriteRule(String pattern,
String prefix)
Deprecated.
|
void |
addRule(Rule rule)
Add a Rule
|
String |
getOriginalPathAttribute() |
org.mortbay.jetty.servlet.PathMap |
getRewrite()
Deprecated.
|
Rule[] |
getRules()
Returns the list of rules.
|
void |
handle(String target,
HttpServletRequest request,
HttpServletResponse response,
int dispatch) |
boolean |
isRewritePathInfo() |
boolean |
isRewriteRequestURI() |
void |
setLegacyRule(LegacyRule legacyRule)
To enable configuration from jetty.xml on rewriteRequestURI, rewritePathInfo and
originalPathAttribute
|
void |
setOriginalPathAttribute(String originalPathAttribute) |
void |
setRewrite(org.mortbay.jetty.servlet.PathMap rewrite)
Deprecated.
|
void |
setRewritePathInfo(boolean rewritePathInfo) |
void |
setRewriteRequestURI(boolean rewriteRequestURI) |
void |
setRules(Rule[] rules)
Assigns the rules to process.
|
void |
setRules(RuleContainer rules)
Assigns the rules to process.
|
addHandler, doStart, doStop, expandChildren, getHandler, removeHandler, setHandler, setServer
expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public void setLegacyRule(LegacyRule legacyRule)
legacyRule
- old style rewrite rulepublic void setRules(Rule[] rules)
rules
- an array of Rule
.public void setRules(RuleContainer rules)
rules
- a RuleContainer
containing other rules to processpublic void addRule(Rule rule)
rule
- The rule to add to the end of the rules arraypublic boolean isRewriteRequestURI()
HttpServletRequest.getRequestURI()
.public void setRewriteRequestURI(boolean rewriteRequestURI)
rewriteRequestURI
- true if this handler will rewrite the value
returned by HttpServletRequest.getRequestURI()
.public boolean isRewritePathInfo()
HttpServletRequest.getPathInfo()
.public void setRewritePathInfo(boolean rewritePathInfo)
rewritePathInfo
- true if this handler will rewrite the value
returned by HttpServletRequest.getPathInfo()
.public String getOriginalPathAttribute()
public void setOriginalPathAttribute(String originalPathAttribute)
originalPathAttribute
- If non null, this string will be used
as the attribute name to store the original request path.public org.mortbay.jetty.servlet.PathMap getRewrite()
public void setRewrite(org.mortbay.jetty.servlet.PathMap rewrite)
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
handle
in interface org.mortbay.jetty.Handler
handle
in class org.mortbay.jetty.handler.HandlerWrapper
IOException
ServletException
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.