public class WebdavServlet extends DefaultServlet
Mapping a subpath (e.g. /webdav/* to this servlet has the effect
of re-mounting the entire web application under that sub-path, with WebDAV
access to all the resources. The WEB-INF and META-INF
directories are protected in this re-mounted resource tree.
To enable WebDAV for a context add the following to web.xml:
<servlet>
<servlet-name>webdav</servlet-name>
<servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
This will enable read only access. To enable read-write access add:
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
To make the content editable via a different URL, use the following
mapping:
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/webdavedit/*</url-pattern>
</servlet-mapping>
By default access to /WEB-INF and META-INF are not available via WebDAV. To
enable access to these URLs, use add:
<init-param>
<param-name>allowSpecialPaths</param-name>
<param-value>true</param-value>
</init-param>
Don't forget to secure access appropriately to the editing URLs, especially
if allowSpecialPaths is used. With the mapping configuration above, the
context will be accessible to normal users as before. Those users with the
necessary access will be able to edit content available via
http://host:port/context/content using
http://host:port/context/webdavedit/contentDefaultServlet.CompressionFormat, DefaultServlet.Range| Modifier and Type | Field and Description |
|---|---|
protected static ConcurrentDateFormat |
creationDateFormat
Simple date format for the creation date ISO representation (partial).
|
protected static java.lang.String |
DEFAULT_NAMESPACE
Default namespace.
|
BUFFER_SIZE, compressionFormats, contextXsltFile, debug, fileEncoding, FULL, globalXsltFile, input, listings, localXsltFile, mimeSeparation, output, readmeFile, readOnly, resources, RESOURCES_JNDI_NAME, sendfileSize, showServerInfo, sm, sortListings, sortManager, useAcceptRanges| Constructor and Description |
|---|
WebdavServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkIfHeaders(HttpServletRequest request,
HttpServletResponse response,
WebResource resource)
Check if the conditions specified in the optional If headers are
satisfied.
|
protected java.lang.String |
determineMethodsAllowed(HttpServletRequest req)
Determines the methods normally allowed for the resource.
|
protected void |
doCopy(HttpServletRequest req,
HttpServletResponse resp)
COPY Method.
|
protected void |
doDelete(HttpServletRequest req,
HttpServletResponse resp)
DELETE Method.
|
protected void |
doLock(HttpServletRequest req,
HttpServletResponse resp)
LOCK Method.
|
protected void |
doMkcol(HttpServletRequest req,
HttpServletResponse resp)
MKCOL Method.
|
protected void |
doMove(HttpServletRequest req,
HttpServletResponse resp)
MOVE Method.
|
protected void |
doOptions(HttpServletRequest req,
HttpServletResponse resp)
OPTIONS Method.
|
protected void |
doPropfind(HttpServletRequest req,
HttpServletResponse resp)
PROPFIND Method.
|
protected void |
doProppatch(HttpServletRequest req,
HttpServletResponse resp)
PROPPATCH Method.
|
protected void |
doPut(HttpServletRequest req,
HttpServletResponse resp)
Process a PUT request for the specified resource.
|
protected void |
doUnlock(HttpServletRequest req,
HttpServletResponse resp)
UNLOCK Method.
|
protected javax.xml.parsers.DocumentBuilder |
getDocumentBuilder()
Return JAXP document builder instance.
|
protected java.lang.String |
getPathPrefix(HttpServletRequest request)
Determines the prefix for standard directory GET listings.
|
protected java.lang.String |
getRelativePath(HttpServletRequest request)
Override the DefaultServlet implementation and only use the PathInfo.
|
protected java.lang.String |
getRelativePath(HttpServletRequest request,
boolean allowEmptyPath) |
void |
init()
Initialize this servlet.
|
protected java.lang.String |
rewriteUrl(java.lang.String path)
URL rewriter.
|
protected void |
service(HttpServletRequest req,
HttpServletResponse resp)
Handles the special WebDAV methods.
|
checkIfMatch, checkIfModifiedSince, checkIfNoneMatch, checkIfUnmodifiedSince, checkSendfile, copy, copy, copy, copy, copy, copy, copyRange, copyRange, copyRange, destroy, doGet, doHead, doPost, executePartialPut, findXsltSource, getReadme, getReadme, parseContentRange, parseRange, render, render, render, renderHtml, renderHtml, renderHtml, renderSize, renderXml, renderXml, renderXml, sendNotAllowed, serveResourcedoTrace, getLastModified, servicegetInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, logprotected static final java.lang.String DEFAULT_NAMESPACE
protected static final ConcurrentDateFormat creationDateFormat
public void init()
throws ServletException
init in class DefaultServletServletException - if an exception occurs that interrupts the servlet's
normal operationprotected javax.xml.parsers.DocumentBuilder getDocumentBuilder()
throws ServletException
ServletException - document builder creation failed
(wrapped ParserConfigurationException exception)protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
service in class DefaultServletreq - the HttpServletRequest object that
contains the request the client made of
the servletresp - the HttpServletResponse object that
contains the response the servlet returns
to the clientServletException - if the HTTP request
cannot be handledjava.io.IOException - if an input or output error occurs
while the servlet is handling the
HTTP requestServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)protected boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response, WebResource resource) throws java.io.IOException
DefaultServletcheckIfHeaders in class DefaultServletrequest - The servlet request we are processingresponse - The servlet response we are creatingresource - The resourcetrue if the resource meets all the specified
conditions, and false if any of the conditions is not
satisfied, in which case request processing is stoppedjava.io.IOException - an IO error occurredprotected java.lang.String rewriteUrl(java.lang.String path)
rewriteUrl in class DefaultServletpath - Path which has to be rewrittenprotected java.lang.String getRelativePath(HttpServletRequest request)
getRelativePath in class DefaultServletrequest - The servlet request we are processingprotected java.lang.String getRelativePath(HttpServletRequest request, boolean allowEmptyPath)
getRelativePath in class DefaultServletprotected java.lang.String getPathPrefix(HttpServletRequest request)
getPathPrefix in class DefaultServletrequest - the request to determine the path forprotected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
doOptions in class DefaultServletreq - The Servlet requestresp - The Servlet responseServletException - If an error occursjava.io.IOException - If an IO error occursprotected void doPropfind(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
req - The Servlet requestresp - The Servlet responseServletException - If an error occursjava.io.IOException - If an IO error occursprotected void doProppatch(HttpServletRequest req, HttpServletResponse resp) throws java.io.IOException
req - The Servlet requestresp - The Servlet responsejava.io.IOException - If an IO error occursprotected void doMkcol(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
req - The Servlet requestresp - The Servlet responseServletException - If an error occursjava.io.IOException - If an IO error occursprotected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
doDelete in class DefaultServletreq - The Servlet requestresp - The Servlet responseServletException - If an error occursjava.io.IOException - If an IO error occursprotected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
doPut in class DefaultServletreq - The servlet request we are processingresp - The servlet response we are creatingjava.io.IOException - if an input/output error occursServletException - if a servlet-specified error occursprotected void doCopy(HttpServletRequest req, HttpServletResponse resp) throws java.io.IOException
req - The Servlet requestresp - The Servlet responsejava.io.IOException - If an IO error occursprotected void doMove(HttpServletRequest req, HttpServletResponse resp) throws java.io.IOException
req - The Servlet requestresp - The Servlet responsejava.io.IOException - If an IO error occursprotected void doLock(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
req - The Servlet requestresp - The Servlet responseServletException - If an error occursjava.io.IOException - If an IO error occursprotected void doUnlock(HttpServletRequest req, HttpServletResponse resp) throws java.io.IOException
req - The Servlet requestresp - The Servlet responsejava.io.IOException - If an IO error occursprotected java.lang.String determineMethodsAllowed(HttpServletRequest req)
determineMethodsAllowed in class DefaultServletreq - The Servlet requestCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.