|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.mmbase.servlet.MMBaseServlet
org.mmbase.servlet.BridgeServlet
org.mmbase.servlet.FileServlet
public class FileServlet
Straight-forward filter which can serve files from one directory (the directory 'files' in the mmbase 'datadir') outside the web application root.
AttachmentServlet,
Serialized Form| Nested Class Summary | |
|---|---|
protected static class |
FileServlet.ChainedRange
This implementation of Range parses and combines a number of FileServlet.FirstLastRanges. |
static class |
FileServlet.DirectoryFunction
The directory as a function. |
protected static class |
FileServlet.FirstLastRange
Implementation of Range simply stating the first and last chars which are available, perhaps with a maximum too. |
protected static interface |
FileServlet.Range
|
| Nested classes/interfaces inherited from class org.mmbase.servlet.BridgeServlet |
|---|
BridgeServlet.QueryParts |
| Field Summary | |
|---|---|
(package private) static String |
PROTECTED_FILES
|
| Fields inherited from class org.mmbase.servlet.BridgeServlet |
|---|
FILE_PATTERN, MESSAGE_ATTRIBUTE |
| Fields inherited from class org.mmbase.servlet.MMBaseServlet |
|---|
mmbase, retryAfter |
| Constructor Summary | |
|---|---|
FileServlet()
|
|
| Method Summary | |
|---|---|
protected boolean |
canRead(HttpServletRequest req,
File f)
Returns whether the given file can be served out for the given request. |
protected File |
checkFile(HttpServletRequest req,
HttpServletResponse resp)
|
protected void |
doGet(HttpServletRequest req,
HttpServletResponse resp)
|
protected void |
doHead(HttpServletRequest req,
HttpServletResponse resp)
|
protected void |
doPut(HttpServletRequest req,
HttpServletResponse resp)
|
protected Map<String,Integer> |
getAssociations()
|
static File |
getDirectory()
|
static File |
getFile(String pathInfo,
ServletResponse res)
|
static FileServlet |
getInstance()
FileServlet should normally be present only once. |
protected long |
getLastModified(HttpServletRequest req)
|
protected byte[] |
getListingBytes(HttpServletRequest req,
HttpServletResponse resp,
File directory)
|
File |
getMetaFile(File f)
FileServlet supports 'meta' files like CERN HTTPD (and apaches mod_cern_meta). |
Map<String,String> |
getMetaHeaders(File f)
Returns contents of getMetaFile(java.io.File) as a Map. |
static String |
getMetaValue(String field,
String value)
Constructs a key/value entry for use in the meta-files. |
protected FileServlet.ChainedRange |
getRange(HttpServletRequest req,
File file)
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html |
String |
getServletInfo()
|
protected static File |
getSessionFile(File f)
|
protected boolean |
ignores(String pi)
|
void |
init()
|
protected void |
listing(HttpServletRequest req,
HttpServletResponse resp,
OutputStream o,
File directory)
|
static String |
parseMetaValue(String fieldName,
String cd)
Parses back the result of getMetaValue(String, String). |
static void |
protectFile(HttpServletRequest req,
File f)
FileServlet can be used to serve files out only to the owner of certain HTTP-session. |
protected void |
setHeaders(HttpServletRequest req,
HttpServletResponse resp,
File file)
|
void |
setMetaHeaders(File f,
Map<String,String> meta)
Sets contents of getMetaFile(java.io.File) as a Map. |
void |
setMMBase(MMBase mmb)
|
protected static void |
stream(FileServlet.ChainedRange range,
InputStream in,
OutputStream out)
|
protected void |
stream(HttpServletRequest req,
HttpServletResponse resp,
OutputStream o,
File file)
|
| Methods inherited from class org.mmbase.servlet.BridgeServlet |
|---|
|
| Methods inherited from class org.mmbase.servlet.MMBaseServlet |
|---|
associateMapping, checkInited, decRefCount, destroy, getBasePath, getMMBase, getRequestURL, getServletByAssociation, getServletByMapping, getServletMappings, getServletMappingsByAssociation, incRefCount, service, setInitException |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doOptions, doPost, doTrace, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final String PROTECTED_FILES
| Constructor Detail |
|---|
public FileServlet()
| Method Detail |
|---|
public void init()
throws ServletException
init in class BridgeServletServletExceptionpublic void setMMBase(MMBase mmb)
setMMBase in interface MMBaseStartersetMMBase in class MMBaseServletpublic String getServletInfo()
getServletInfo in interface ServletgetServletInfo in class MMBaseServletprotected Map<String,Integer> getAssociations()
getAssociations in class MMBaseServletpublic static FileServlet getInstance()
getDirectory().
null if there isn't one.public static File getDirectory()
public static File getFile(String pathInfo,
ServletResponse res)
protected static File getSessionFile(File f)
public static void protectFile(HttpServletRequest req,
File f)
throws IOException
IOException
protected boolean canRead(HttpServletRequest req,
File f)
protectFile(javax.servlet.http.HttpServletRequest, java.io.File) to make the file only accessible to the current http session.
protected boolean ignores(String pi)
public File getMetaFile(File f)
.web/<filename>.meta.
public Map<String,String> getMetaHeaders(File f)
getMetaFile(java.io.File) as a Map.
public void setMetaHeaders(File f,
Map<String,String> meta)
getMetaFile(java.io.File) as a Map.
public static String parseMetaValue(String fieldName,
String cd)
getMetaValue(String, String).
E.g. to get the filename back from the content disposition in the meta header maps do:
String inDisposition = FileServlet.parseMetaValue("filename", meta.get("Content-Disposition"));
public static String getMetaValue(String field,
String value)
meta.put("Content-Disposition", "attachment; " + FileServlet.getMetaValue("filename", name));
protected File checkFile(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
ServletException
IOException
protected void setHeaders(HttpServletRequest req,
HttpServletResponse resp,
File file)
throws ServletException,
IOException
ServletException
IOException
protected void doHead(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doHead in class HttpServletServletException
IOException
protected void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doGet in class MMBaseServletServletException
IOException
protected FileServlet.ChainedRange getRange(HttpServletRequest req,
File file)
null otherwise.
protected static void stream(FileServlet.ChainedRange range,
InputStream in,
OutputStream out)
throws IOException
IOException
protected void stream(HttpServletRequest req,
HttpServletResponse resp,
OutputStream o,
File file)
throws IOException
IOException
protected byte[] getListingBytes(HttpServletRequest req,
HttpServletResponse resp,
File directory)
throws IOException
IOException
protected void listing(HttpServletRequest req,
HttpServletResponse resp,
OutputStream o,
File directory)
throws IOException
IOException
protected void doPut(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doPut in class HttpServletServletException
IOExceptionprotected long getLastModified(HttpServletRequest req)
getLastModified in class BridgeServlet
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||