Apache Tomcat 7.0.37

org.apache.catalina.servlets
Class WebdavServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.catalina.servlets.DefaultServlet
              extended by org.apache.catalina.servlets.WebdavServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

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.

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. This 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/content

Version:
$Id: WebdavServlet.java 1364451 2012-07-22 22:23:22Z markt $
Author:
Remy Maucherat
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.catalina.servlets.DefaultServlet
DefaultServlet.Range
 
Field Summary
protected static SimpleDateFormat creationDateFormat
          Simple date format for the creation date ISO representation (partial).
protected static String DEFAULT_NAMESPACE
          Default namespace.
protected static MD5Encoder md5Encoder
          Deprecated. Unused - will be removed in Tomcat 8.0.x
protected static MessageDigest md5Helper
          MD5 message digest provider.
 
Fields inherited from class org.apache.catalina.servlets.DefaultServlet
BUFFER_SIZE, contextXsltFile, debug, fileEncoding, FULL, globalXsltFile, input, listings, localXsltFile, mimeSeparation, output, readmeFile, readOnly, resources, RESOURCES_JNDI_NAME, sendfileSize, sm, urlEncoder, useAcceptRanges
 
Constructor Summary
WebdavServlet()
           
 
Method Summary
protected  boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response, ResourceAttributes resourceAttributes)
          Check if the conditions specified in the optional If headers are satisfied.
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  DocumentBuilder getDocumentBuilder()
          Return JAXP document builder instance.
protected  String getPathPrefix(HttpServletRequest request)
          Determines the prefix for standard directory GET listings.
protected  String getRelativePath(HttpServletRequest request)
          Override the DefaultServlet implementation and only use the PathInfo.
 void init()
          Initialize this servlet.
protected  void service(HttpServletRequest req, HttpServletResponse resp)
          Handles the special WebDAV methods.
 
Methods inherited from class org.apache.catalina.servlets.DefaultServlet
checkIfMatch, checkIfModifiedSince, checkIfNoneMatch, checkIfUnmodifiedSince, checkSendfile, copy, copy, copy, copy, copyRange, copyRange, copyRange, destroy, displaySize, doGet, doHead, doPost, executePartialPut, findXsltInputStream, getReadme, parseContentRange, parseRange, render, renderHtml, renderSize, renderXml, rewriteUrl, serveResource
 
Methods inherited from class javax.servlet.http.HttpServlet
doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE

protected static final String DEFAULT_NAMESPACE
Default namespace.

See Also:
Constant Field Values

creationDateFormat

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


md5Helper

protected static MessageDigest md5Helper
MD5 message digest provider.


md5Encoder

@Deprecated
protected static final MD5Encoder md5Encoder
Deprecated. Unused - will be removed in Tomcat 8.0.x
The MD5 helper object for this class.

Constructor Detail

WebdavServlet

public WebdavServlet()
Method Detail

init

public void init()
          throws ServletException
Initialize this servlet.

Overrides:
init in class DefaultServlet
Throws:
ServletException - if an exception occurs that interrupts the servlet's normal operation

getDocumentBuilder

protected DocumentBuilder getDocumentBuilder()
                                      throws ServletException
Return JAXP document builder instance.

Throws:
ServletException

service

protected void service(HttpServletRequest req,
                       HttpServletResponse resp)
                throws ServletException,
                       IOException
Handles the special WebDAV methods.

Overrides:
service in class HttpServlet
Parameters:
req - the HttpServletRequest object that contains the request the client made of the servlet
resp - the HttpServletResponse object that contains the response the servlet returns to the client
Throws:
ServletException - if the HTTP request cannot be handled
IOException - if an input or output error occurs while the servlet is handling the HTTP request
See Also:
Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)

checkIfHeaders

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

Overrides:
checkIfHeaders in class DefaultServlet
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
Throws:
IOException

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.

Overrides:
getRelativePath in class DefaultServlet
Parameters:
request - The servlet request we are processing

getPathPrefix

protected String getPathPrefix(HttpServletRequest request)
Determines the prefix for standard directory GET listings.

Overrides:
getPathPrefix in class DefaultServlet
Parameters:
request - the request to determine the path for
Returns:
the prefix to apply to all resources in the listing.

doOptions

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

Overrides:
doOptions in class DefaultServlet
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)
                   throws ServletException,
                          IOException
PROPFIND Method.

Throws:
ServletException
IOException

doProppatch

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

Throws:
IOException

doMkcol

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

Throws:
ServletException
IOException

doDelete

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

Overrides:
doDelete in class DefaultServlet
Parameters:
req - The servlet request we are processing
resp - The servlet response we are creating
Throws:
ServletException - if a servlet-specified error occurs
IOException - if an input/output error occurs

doPut

protected void doPut(HttpServletRequest req,
                     HttpServletResponse resp)
              throws ServletException,
                     IOException
Process a PUT request for the specified resource.

Overrides:
doPut in class DefaultServlet
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

doCopy

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

Throws:
IOException

doMove

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

Throws:
IOException

doLock

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

Throws:
ServletException
IOException

doUnlock

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

Throws:
IOException

Apache Tomcat 7.0.37

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.