public class TryFilesFilter
extends java.lang.Object
implements javax.servlet.Filter
This filter accepts the files init-param as a list of space-separated
file URIs. The special token $path represents the current request URL's
path (the portion after the context path).
Typical example of how this filter can be configured is the following:
<filter>
<filter-name>try_files</filter-name>
<filter-class>org.eclipse.jetty.fcgi.server.proxy.TryFilesFilter</filter-class>
<init-param>
<param-name>files</param-name>
<param-value>maintenance.html $path index.php?p=$path</param-value>
</init-param>
</filter>
For a request such as /context/path/to/resource.ext, this filter will
try to serve the /maintenance.html file if it finds it; failing that,
it will try to serve the /path/to/resource.ext file if it finds it;
failing that it will forward the request to index.php?p=/path/to/resource.ext.
The last file URI specified in the list is therefore the "fallback" to which the request
is forwarded to in case no previous files can be found.
The files are resolved using ServletContext.getResource(String) to make sure
that only files visible to the application are served.
FastCGIProxyServlet| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
FILES_INIT_PARAM |
| Constructor and Description |
|---|
TryFilesFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
protected void |
fallback(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain,
java.lang.String fallback) |
void |
init(javax.servlet.FilterConfig config) |
public static final java.lang.String FILES_INIT_PARAM
public void init(javax.servlet.FilterConfig config)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterjavax.servlet.ServletExceptionpublic void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws java.io.IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.Filterjava.io.IOExceptionjavax.servlet.ServletExceptionprotected void fallback(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain,
java.lang.String fallback)
throws java.io.IOException,
javax.servlet.ServletException
java.io.IOExceptionjavax.servlet.ServletExceptionpublic void destroy()
destroy in interface javax.servlet.FilterCopyright © 1995–2018 Webtide. All rights reserved.