org.apache.catalina.servlets

Class WebdavServlet

public class WebdavServlet extends DefaultServlet

Servlet which adds support for WebDAV level 2. All the basic HTTP requests are handled by the DefaultServlet. The WebDAVServlet must not be used as the default servlet (ie mapped to '/') as it will not work in this configuration. 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>true</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, using the following mapping:
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/webdavedit/*</url-pattern>
</servlet-mapping>

Don't forget to secure access appropriately to the editing URLs. With this configuration 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/content

Version: $Revision: 769338 $ $Date: 2009-04-28 13:25:01 +0200 (Tue, 28 Apr 2009) $

Author: Remy Maucherat

Field Summary
protected static SimpleDateFormatcreationDateFormat
Simple date format for the creation date ISO representation (partial).
protected static StringDEFAULT_NAMESPACE
Default namespace.
protected static MD5Encodermd5Encoder
The MD5 helper object for this class.
protected static MessageDigestmd5Helper
MD5 message digest provider.
Method Summary
protected booleancheckIfHeaders(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes)
Check if the conditions specified in the optional If headers are satisfied.
protected voiddoCopy(HttpServletRequest req, HttpServletResponse resp)
COPY Method.
protected voiddoDelete(HttpServletRequest req, HttpServletResponse resp)
DELETE Method.
protected voiddoLock(HttpServletRequest req, HttpServletResponse resp)
LOCK Method.
protected voiddoMkcol(HttpServletRequest req, HttpServletResponse resp)
MKCOL Method.
protected voiddoMove(HttpServletRequest req, HttpServletResponse resp)
MOVE Method.
protected voiddoOptions(HttpServletRequest req, HttpServletResponse resp)
OPTIONS Method.
protected voiddoPropfind(HttpServletRequest req, HttpServletResponse resp)
PROPFIND Method.
protected voiddoProppatch(HttpServletRequest req, HttpServletResponse resp)
PROPPATCH Method.
protected voiddoPut(HttpServletRequest req, HttpServletResponse resp)
Process a POST request for the specified resource.
protected voiddoUnlock(HttpServletRequest req, HttpServletResponse resp)
UNLOCK Method.
protected DocumentBuildergetDocumentBuilder()
Return JAXP document builder instance.
protected StringgetRelativePath(HttpServletRequest request)
Override the DefaultServlet implementation and only use the PathInfo.
voidinit()
Initialize this servlet.
protected voidservice(HttpServletRequest req, HttpServletResponse resp)
Handles the special WebDAV methods.

Field Detail

creationDateFormat

protected static final SimpleDateFormat creationDateFormat
Simple date format for the creation date ISO representation (partial).

DEFAULT_NAMESPACE

protected static final String DEFAULT_NAMESPACE
Default namespace.

md5Encoder

protected static final MD5Encoder md5Encoder
The MD5 helper object for this class.

md5Helper

protected static MessageDigest md5Helper
MD5 message digest provider.

Method Detail

checkIfHeaders

protected boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes)
Check if the conditions specified in the optional If headers are satisfied.

Parameters: request The servlet request we are processing response The servlet response we are creating resourceAttributes The resource information

Returns: boolean true if the resource meets all the specified conditions, and false if any of the conditions is not satisfied, in which case request processing is stopped

doCopy

protected void doCopy(HttpServletRequest req, HttpServletResponse resp)
COPY Method.

doDelete

protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
DELETE Method.

doLock

protected void doLock(HttpServletRequest req, HttpServletResponse resp)
LOCK Method.

doMkcol

protected void doMkcol(HttpServletRequest req, HttpServletResponse resp)
MKCOL Method.

doMove

protected void doMove(HttpServletRequest req, HttpServletResponse resp)
MOVE Method.

doOptions

protected void doOptions(HttpServletRequest req, HttpServletResponse resp)
OPTIONS Method.

Parameters: req The request resp The response

Throws: ServletException If an error occurs IOException If an IO error occurs

doPropfind

protected void doPropfind(HttpServletRequest req, HttpServletResponse resp)
PROPFIND Method.

doProppatch

protected void doProppatch(HttpServletRequest req, HttpServletResponse resp)
PROPPATCH Method.

doPut

protected void doPut(HttpServletRequest req, HttpServletResponse resp)
Process a POST request for the specified resource.

Parameters: req The servlet request we are processing resp The servlet response we are creating

Throws: IOException if an input/output error occurs ServletException if a servlet-specified error occurs

doUnlock

protected void doUnlock(HttpServletRequest req, HttpServletResponse resp)
UNLOCK Method.

getDocumentBuilder

protected DocumentBuilder getDocumentBuilder()
Return JAXP document builder instance.

getRelativePath

protected String getRelativePath(HttpServletRequest request)
Override the DefaultServlet implementation and only use the PathInfo. If the ServletPath is non-null, it will be because the WebDAV servlet has been mapped to a url other than /* to configure editing at different url than normal viewing.

Parameters: request The servlet request we are processing

init

public void init()
Initialize this servlet.

service

protected void service(HttpServletRequest req, HttpServletResponse resp)
Handles the special WebDAV methods.
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.