Class WebdavServlet
- All Implemented Interfaces:
- Servlet,- ServletConfig,- Serializable,- PeriodicEventListener
The WebDAV servlet is only designed for use with path mapping. The WebdavServlet must not be used as the default servlet (i.e. mapped to '/') or with any other mapping types as it will not work in those configurations.
 By default, the entire web application is exposed via the WebDAV servlet. Mapping the WebDAV servlet to
 /* provides WebDAV access to all the resources within the web application. To aid separation of normal
 users and WebDAV users, the WebDAV servlet may be mounted at a sub-path (e.g. /webdav/*) which creates
 an additional mapping for the entire web application under that sub-path, with WebDAV access to all the resources.
 
 By default, the WEB-INF and META-INF directories are not accessible via WebDAV. This may
 be changed by setting the allowSpecialPaths initialisation parameter to true.
 
 It is also possible to enable WebDAV access to a sub-set of the standard web application URL space rather than
 creating an additional, WebDAV specific mapping. To do this, map the WebDAV servlet to the desired sub-path and set
 the serveSubpathOnly initialisation parameter to true.
 
 Security constraints using the same URL pattern as the mapping (e.g. /webdav/*) can be used to limit the
 users with access to WebDAV functionality. Care is required if using security constraints to further limit WebDAV
 functionality. In particular, administrators should be aware that security constraints apply only to the request URL.
 Security constraints do not apply to any destination URL associated with the WebDAV operation (such as COPY or MOVE).
 
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 with folder listings enabled. 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, 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
 
 The Servlet provides support for arbitrary dead properties on all resources (dead properties are properties whose
 values are not protected by the server, such as the content length of a resource). By default the Servlet will use
 non persistent memory storage for them. Persistence can be achieved by implementing the PropertyStore
 interface and configuring the Servlet to use that store. The propertyStore init-param allows configuring
 the class name of the store to use, while the parameters in the form of store.xxx will be set on the
 store object as bean properties. For example, this would configure a store with class
 com.MyPropertyStore, and set its property myName to value myValue:
 
  <init-param>
    <param-name>propertyStore</param-name>
    <param-value>com.MyPropertyStore</param-value>
  </init-param>
  <init-param>
    <param-name>store.myName</param-name>
    <param-value>myValue</param-value>
  </init-param>
 
 - See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classDefault property store, which provides memory storage without persistence.static interfaceHandling of dead properties on resources.static classRepresents a PROPPATCH sub operation to be performed.Nested classes/interfaces inherited from class org.apache.catalina.servlets.DefaultServletDefaultServlet.CompressionFormat
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final ConcurrentDateFormatSimple date format for the creation date ISO representation (partial).protected static final StringDefault namespace.protected static final StringLock scheme used.protected static final StringPre generated raw XML for supported locks.Fields inherited from class org.apache.catalina.servlets.DefaultServletBUFFER_SIZE, compressionFormats, contextXsltFile, debug, fileEncoding, FULL, globalXsltFile, input, listings, localXsltFile, mimeSeparation, output, readmeFile, readOnly, resources, sendfileSize, showServerInfo, sm, sortListings, sortManager, useAcceptRangesFields inherited from class jakarta.servlet.http.HttpServletLEGACY_DO_HEAD
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleancheckIfHeaders(HttpServletRequest request, HttpServletResponse response, WebResource resource) Check if the conditions specified in the optional If headers are satisfied.voiddestroy()Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.protected StringDetermines the methods normally allowed for the resource.protected voiddoCopy(HttpServletRequest req, HttpServletResponse resp) COPY Method.protected voiddoDelete(HttpServletRequest req, HttpServletResponse resp) Called by the server (via theservicemethod) to allow a servlet to handle a DELETE request.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) Override default implementation to ensure that TRACE is correctly handled.protected voiddoPropfind(HttpServletRequest req, HttpServletResponse resp) PROPFIND Method.protected voiddoProppatch(HttpServletRequest req, HttpServletResponse resp) PROPPATCH Method.protected voiddoPut(HttpServletRequest req, HttpServletResponse resp) Called by the server (via theservicemethod) to allow a servlet to handle a PUT request.protected voiddoUnlock(HttpServletRequest req, HttpServletResponse resp) UNLOCK Method.protected DocumentBuilderReturn JAXP document builder instance.protected StringgetPathPrefix(HttpServletRequest request) Determines the appropriate path to prepend resources with when generating directory listings.protected StringgetRelativePath(HttpServletRequest request, boolean allowEmptyPath) Override the DefaultServlet implementation and only use the PathInfo.voidinit()A convenience method which can be overridden so that there's no need to callsuper.init(config).voidExecute a periodic task, such as reloading, etc.protected voidservice(HttpServletRequest req, HttpServletResponse resp) Receives standard HTTP requests from the publicservicemethod and dispatches them to thedoMethod methods defined in this class.Methods inherited from class org.apache.catalina.servlets.DefaultServletcheckIfMatch, checkIfModifiedSince, checkIfNoneMatch, checkIfRange, checkIfUnmodifiedSince, checkSendfile, copy, copy, copy, copy, copyRange, copyRange, copyRange, doGet, doHead, doPost, executePartialPut, findXsltSource, generateETag, getReadme, getRelativePath, isListings, isRangeRequestsSupported, isReadOnly, parseContentRange, parseRange, render, renderHtml, renderSize, renderTimestamp, renderXml, rewriteUrl, sendNotAllowed, serveResourceMethods inherited from class jakarta.servlet.http.HttpServletdoTrace, getLastModified, init, serviceMethods inherited from class jakarta.servlet.GenericServletgetInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log
- 
Field Details- 
DEFAULT_NAMESPACE
- 
SUPPORTED_LOCKS
- 
creationDateFormatSimple date format for the creation date ISO representation (partial).
- 
LOCK_SCHEME
 
- 
- 
Constructor Details- 
WebdavServletpublic WebdavServlet()
 
- 
- 
Method Details- 
initDescription copied from class:jakarta.servlet.GenericServletA convenience method which can be overridden so that there's no need to callsuper.init(config).Instead of overriding GenericServlet.init(ServletConfig), simply override this method and it will be called byGenericServlet.init(ServletConfig config). TheServletConfigobject can still be retrieved viaGenericServlet.getServletConfig().- Overrides:
- initin class- DefaultServlet
- Throws:
- ServletException- if an exception occurs that interrupts the servlet's normal operation
 
- 
destroypublic void destroy()Description copied from class:jakarta.servlet.GenericServletCalled by the servlet container to indicate to a servlet that the servlet is being taken out of service. SeeServlet.destroy().- Specified by:
- destroyin interface- Servlet
- Overrides:
- destroyin class- DefaultServlet
 
- 
periodicEventpublic void periodicEvent()Description copied from interface:PeriodicEventListenerExecute a periodic task, such as reloading, etc.- Specified by:
- periodicEventin interface- PeriodicEventListener
 
- 
getDocumentBuilderReturn JAXP document builder instance.- Returns:
- the document builder
- Throws:
- ServletException- document builder creation failed (wrapped- ParserConfigurationExceptionexception)
 
- 
serviceprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException Description copied from class:jakarta.servlet.http.HttpServletReceives standard HTTP requests from the publicservicemethod and dispatches them to thedoMethod methods defined in this class. This method is an HTTP-specific version of theServlet.service(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse)method. There's no need to override this method.- Overrides:
- servicein class- DefaultServlet
- Parameters:
- req- the- HttpServletRequestobject that contains the request the client made of the servlet
- resp- the- HttpServletResponseobject 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:
 
- 
checkIfHeadersprotected boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response, WebResource resource) throws IOException Description copied from class:DefaultServletCheck if the conditions specified in the optional If headers are satisfied.- Overrides:
- checkIfHeadersin class- DefaultServlet
- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- resource- The resource
- Returns:
- trueif the resource meets all the specified conditions, and- falseif any of the conditions is not satisfied, in which case request processing is stopped
- Throws:
- IOException- an IO error occurred
 
- 
getRelativePathOverride 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:
- getRelativePathin class- DefaultServlet
- Parameters:
- request- The servlet request we are processing
- allowEmptyPath- Used only to identify a call from DefaultServlet, to avoid removing the trailing slash
- Returns:
- the relative path
 
- 
getPathPrefixDescription copied from class:DefaultServletDetermines the appropriate path to prepend resources with when generating directory listings. Depending on the behaviour ofDefaultServlet.getRelativePath(HttpServletRequest)this will change.- Overrides:
- getPathPrefixin class- DefaultServlet
- Parameters:
- request- the request to determine the path for
- Returns:
- the prefix to apply to all resources in the listing.
 
- 
determineMethodsAllowedDescription copied from class:DefaultServletDetermines the methods normally allowed for the resource.- Overrides:
- determineMethodsAllowedin class- DefaultServlet
- Parameters:
- req- The Servlet request
- Returns:
- The allowed HTTP methods
 
- 
doOptionsprotected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException Description copied from class:DefaultServletOverride default implementation to ensure that TRACE is correctly handled.- Overrides:
- doOptionsin class- DefaultServlet
- Parameters:
- req- the- HttpServletRequestobject that contains the request the client made of the servlet
- resp- the- HttpServletResponseobject that contains the response the servlet returns to the client
- Throws:
- ServletException- if the request for the OPTIONS cannot be handled
- IOException- if an input or output error occurs while the servlet is handling the OPTIONS request
 
- 
doPropfindprotected void doPropfind(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException PROPFIND Method.- Parameters:
- req- The Servlet request
- resp- The Servlet response
- Throws:
- ServletException- If an error occurs
- IOException- If an IO error occurs
 
- 
doProppatchprotected void doProppatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException PROPPATCH Method. Dead properties support is a SHOULD in the specification and are not implemented.- Parameters:
- req- The Servlet request
- resp- The Servlet response
- Throws:
- ServletException- If an error occurs
- IOException- If an IO error occurs
 
- 
doMkcolprotected void doMkcol(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException MKCOL Method.- Parameters:
- req- The Servlet request
- resp- The Servlet response
- Throws:
- ServletException- If an error occurs
- IOException- If an IO error occurs
 
- 
doDeleteprotected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException Description copied from class:jakarta.servlet.http.HttpServletCalled by the server (via theservicemethod) to allow a servlet to handle a DELETE request. The DELETE operation allows a client to remove a document or Web page from the server.This method does not need to be either safe or idempotent. Operations requested through DELETE can have side effects for which users can be held accountable. When using this method, it may be useful to save a copy of the affected URL in temporary storage. If the HTTP DELETE request is incorrectly formatted, doDeletereturns an HTTP "Bad Request" message.- Overrides:
- doDeletein class- DefaultServlet
- Parameters:
- req- the- HttpServletRequestobject that contains the request the client made of the servlet
- resp- the- HttpServletResponseobject that contains the response the servlet returns to the client
- Throws:
- ServletException- if the request for the DELETE cannot be handled
- IOException- if an input or output error occurs while the servlet is handling the DELETE request
 
- 
doPutprotected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException Description copied from class:jakarta.servlet.http.HttpServletCalled by the server (via theservicemethod) to allow a servlet to handle a PUT request. The PUT operation allows a client to place a file on the server and is similar to sending a file by FTP.When overriding this method, leave intact any content headers sent with the request (including Content-Length, Content-Type, Content-Transfer-Encoding, Content-Encoding, Content-Base, Content-Language, Content-Location, Content-MD5, and Content-Range). If your method cannot handle a content header, it must issue an error message (HTTP 501 - Not Implemented) and discard the request. For more information on HTTP 1.1, see RFC 2616 . This method does not need to be either safe or idempotent. Operations that doPutperforms can have side effects for which the user can be held accountable. When using this method, it may be useful to save a copy of the affected URL in temporary storage.If the HTTP PUT request is incorrectly formatted, doPutreturns an HTTP "Bad Request" message.- Overrides:
- doPutin class- DefaultServlet
- Parameters:
- req- the- HttpServletRequestobject that contains the request the client made of the servlet
- resp- the- HttpServletResponseobject that contains the response the servlet returns to the client
- Throws:
- ServletException- if the request for the PUT cannot be handled
- IOException- if an input or output error occurs while the servlet is handling the PUT request
 
- 
doCopyCOPY Method.- Parameters:
- req- The Servlet request
- resp- The Servlet response
- Throws:
- IOException- If an IO error occurs
 
- 
doMoveMOVE Method.- Parameters:
- req- The Servlet request
- resp- The Servlet response
- Throws:
- IOException- If an IO error occurs
 
- 
doLockprotected void doLock(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException LOCK Method.- Parameters:
- req- The Servlet request
- resp- The Servlet response
- Throws:
- ServletException- If an error occurs
- IOException- If an IO error occurs
 
- 
doUnlockUNLOCK Method.- Parameters:
- req- The Servlet request
- resp- The Servlet response
- Throws:
- IOException- If an IO error occurs
 
 
-