This path uses the pattern matching of PathMap to rewrite URI's
of received requests. A typical jetty.xml configuration would be:
<Set name="handler">
<New id="Handlers" class="org.mortbay.jetty.handler.RewriteHandler">
<Set name="rewriteRequestURI">false</Set>
<Set name="rewritePathInfo">false</Set>
<Set name="originalPathAttribute">requestedPath</Set>
<Call name="addRewriteRule"><Arg>/other/*</Arg><Arg>/test</Arg></Call>
<Call name="addRewriteRule"><Arg>/test/*</Arg><Arg></Arg></Call>
<Call name="addRewriteRule"><Arg>/*</Arg><Arg>/test</Arg></Call>
<Set name="handler">
<New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.mortbay.jetty.Handler">
<Item>
<New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
</New>
</Set>
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private PathMap | |
| private boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addRewriteRule(String
The path pattern to match. The pattern must start with / and may use
a trailing /* as a wildcard. pattern, String The path prefix which will replace the matching part of the path. prefix)Add a path rewriting rule |
| public String | Returns: the originalPathAttribte. If non null, this string will be used as the attribute name to store the original request path.
|
| public PathMap | |
| public void | handle(String
The target of the request - either a URI or a name. target, HttpServletRequest The request either as the request, HttpServletResponse Request
object or a wrapper of that request. The HttpConnection#getCurrentConnection()
method can be used access the Request object if required.The response as the response, int dispatch)Response
object or a wrapper of that request. The HttpConnection#getCurrentConnection()
method can be used access the Response object if required.Overrides org. Implements org. |
| public boolean | Returns: true if this handler will rewrite the value returned byHttpServletRequest#getPathInfo().
|
| public boolean | Returns: the rewriteRequestURI If true, this handler will rewrite the value returned byHttpServletRequest#getRequestURI().
|
| public void | setOriginalPathAttribute(String
If non null, this string will be used
as the attribute name to store the original request path. originalPathAttribte)
|
| public void | |
| public void | setRewritePathInfo(boolean
true if this handler will rewrite the value
returned by rewritePathInfo)HttpServletRequest#getPathInfo().
|
| public void | setRewriteRequestURI(boolean
true if this handler will rewrite the value
returned by rewriteRequestURI)HttpServletRequest#getRequestURI().
|
| _originalPathAttribute | back to summary |
|---|---|
| private String _originalPathAttribute | |
| _rewrite | back to summary |
|---|---|
| private PathMap _rewrite | |
| _rewritePathInfo | back to summary |
|---|---|
| private boolean _rewritePathInfo | |
| _rewriteRequestURI | back to summary |
|---|---|
| private boolean _rewriteRequestURI | |
| RewriteHandler | back to summary |
|---|---|
| public RewriteHandler() | |
| addRewriteRule | back to summary |
|---|---|
| public void addRewriteRule(String pattern, String prefix) Add a path rewriting rule | |
| getOriginalPathAttribute | back to summary |
|---|---|
public String getOriginalPathAttribute()
| |
| getRewrite | back to summary |
|---|---|
| public PathMap getRewrite() | |
| handle | back to summary |
|---|---|
| public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException Overrides org. Implements org. Doc from org. Handle a request.
| |
| isRewritePathInfo | back to summary |
|---|---|
public boolean isRewritePathInfo()
| |
| isRewriteRequestURI | back to summary |
|---|---|
public boolean isRewriteRequestURI()
| |
| setOriginalPathAttribute | back to summary |
|---|---|
public void setOriginalPathAttribute(String originalPathAttribte)
| |
| setRewrite | back to summary |
|---|---|
| public void setRewrite(PathMap rewrite) | |
| setRewritePathInfo | back to summary |
|---|---|
public void setRewritePathInfo(boolean rewritePathInfo)
| |
| setRewriteRequestURI | back to summary |
|---|---|
public void setRewriteRequestURI(boolean rewriteRequestURI)
| |