org.apache.catalina.servlets.WebdavServlet类的使用及代码示例 您所在的位置:网站首页 webdavservlet org.apache.catalina.servlets.WebdavServlet类的使用及代码示例

org.apache.catalina.servlets.WebdavServlet类的使用及代码示例

2023-03-01 11:53| 来源: 网络整理| 查看: 265

本文整理了Java中org.apache.catalina.servlets.WebdavServlet类的一些代码示例,展示了WebdavServlet类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebdavServlet类的具体详情如下:包路径:org.apache.catalina.servlets.WebdavServlet类名称:WebdavServlet

WebdavServlet介绍

[英]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:

webdav org.apache.catalina.servlets.WebdavServlet debug 0 listings false webdav /*

This will enable read only access. To enable read-write access add:

readonly false

To make the content editable via a different URL, use the following mapping:

webdav /webdavedit/*

By default access to /WEB-INF and META-INF are not available via WebDAV. To enable access to these URLs, use add:

allowSpecialPaths true

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[中]Servlet增加了对WebDAV级别2的支持。所有基本HTTP请求都由DefaultServlet处理。WebDAVServlet不能用作默认servlet(即映射到“/”),因为它在此配置中不起作用。将子路径(例如,/webdav/*映射到此servlet,可以在该子路径下重新装载整个web应用程序,WebDAV可以访问所有资源。此WEB-INF和META-INF目录在重新装载的资源树中受到保护。要为上下文启用WebDAV,请将以下内容添加到web。xml:

webdav org.apache.catalina.servlets.WebdavServlet debug 0 listings false webdav /*

这将启用只读访问。要启用读写访问,请添加:

readonly false

要通过其他URL编辑内容,请使用以下映射:

webdav /webdavedit/*

默认情况下,通过WebDAV无法访问/WEB-INF和META-INF。要启用对这些URL的访问,请使用add:

allowSpecialPaths true

不要忘记适当保护对编辑URL的访问,尤其是在使用AllowSpecialPath的情况下。通过上面的映射配置,正常用户可以像以前一样访问上下文。拥有必要访问权限的用户将能够通过http://host:port/context/content使用http://host:port/context/webdavedit/content

代码示例

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

/** * MOVE Method. */ protected void doMove(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } String path = getRelativePath(req); if (copyResource(req, resp)) { deleteResource(path, req, resp, false); } }

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/** * OPTIONS Method. * * @param req The Servlet request * @param resp The Servlet response * @throws ServletException If an error occurs * @throws IOException If an IO error occurs */ @Override protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.addHeader("DAV", "1,2"); resp.addHeader("Allow", determineMethodsAllowed(req)); resp.addHeader("MS-Author-Via", "DAV"); }

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

/** * Delete a resource. * * @param req Servlet request * @param resp Servlet response * @return boolean true if the copy is successful */ private boolean deleteResource(HttpServletRequest req, HttpServletResponse resp) throws IOException { String path = getRelativePath(req); return deleteResource(path, req, resp, true); }

代码示例来源:origin: org.glassfish.main.web/web-core

/** * DELETE Method. */ protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } deleteResource(req, resp); }

代码示例来源:origin: org.glassfish.main.web/web-core

/** * Handles the special WebDAV methods. */ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String method = req.getMethod(); if (debug > 0) { String path = getRelativePath(req); log("[" + method + "] " + path); } if (method.equals(METHOD_PROPFIND)) { doPropfind(req, resp); } else if (method.equals(METHOD_PROPPATCH)) { doProppatch(req, resp); } else if (method.equals(METHOD_MKCOL)) { doMkcol(req, resp); } else if (method.equals(METHOD_COPY)) { doCopy(req, resp); } else if (method.equals(METHOD_MOVE)) { doMove(req, resp); } else if (method.equals(METHOD_LOCK)) { doLock(req, resp); } else if (method.equals(METHOD_UNLOCK)) { doUnlock(req, resp); } else { // DefaultServlet processing super.service(req, resp); } }

代码示例来源:origin: codefollower/Tomcat-Research

if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; String path = getRelativePath(req); StringBuilder methodsAllowed = determineMethodsAllowed(req); DocumentBuilder documentBuilder = getDocumentBuilder(); try {

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

log("Delete:" + path); if (isSpecialPath(path)) { errorList.put(path, Integer.valueOf(WebdavStatus.SC_FORBIDDEN)); return; childName += entry; if (isLocked(childName, ifHeader + lockTokenHeader)) { WebResource childResource = resources.getResource(childName); if (childResource.isDirectory()) { deleteCollection(req, childName, errorList);

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

lockTokenHeader = ""; if (isLocked(path, ifHeader + lockTokenHeader)) { resp.sendError(WebdavStatus.SC_LOCKED); return false; new Hashtable(); deleteCollection(req, resources, path, errorList); try { resources.unbind(path); sendReport(req, resp, errorList); return false;

代码示例来源:origin: org.jboss.web/jbossweb

StringBuilder methodsAllowed = determineMethodsAllowed(resources, req); String path = getRelativePath(req); if (path.endsWith("/")) path = path.substring(0, path.length() - 1); DocumentBuilder documentBuilder = getDocumentBuilder(); generatedXML.writeElement (null, "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING); parseLockNullProperties (req, generatedXML, lockNullPath, type, properties); + generateNamespaceDeclarations(), XMLWriter.OPENING); parseProperties(req, generatedXML, path, type, properties); } else { parseProperties(req, generatedXML, currentPath, type, properties); String lockNullPath = lockNullResourcesList.nextElement();

代码示例来源:origin: org.jboss.web/jbossweb

log("Delete:" + path); childName += ncPair.getName(); if (isLocked(childName, ifHeader + lockTokenHeader)) { Object object = resources.lookup(childName); if (object instanceof DirContext) { deleteCollection(req, resources, childName, errorList);

代码示例来源:origin: codefollower/Tomcat-Research

/** * COPY Method. */ protected void doCopy(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } copyResource(req, resp); }

代码示例来源:origin: org.jboss.web/jbossweb

log("Copy: " + source + " To: " + dest); childSrc += "/"; childSrc += ncPair.getName(); copyResource(resources, errorList, childSrc, childDest);

代码示例来源:origin: org.jboss.web/jbossweb

/** * Handles the special WebDAV methods. */ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String method = req.getMethod(); if (debug > 0) { String path = getRelativePath(req); log("[" + method + "] " + path); } if (method.equals(METHOD_PROPFIND)) { doPropfind(req, resp); } else if (method.equals(METHOD_PROPPATCH)) { doProppatch(req, resp); } else if (method.equals(METHOD_MKCOL)) { doMkcol(req, resp); } else if (method.equals(METHOD_COPY)) { doCopy(req, resp); } else if (method.equals(METHOD_MOVE)) { doMove(req, resp); } else if (method.equals(METHOD_LOCK)) { doLock(req, resp); } else if (method.equals(METHOD_UNLOCK)) { doUnlock(req, resp); } else { // DefaultServlet processing super.service(req, resp); } }

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; String path = getRelativePath(req); StringBuilder methodsAllowed = determineMethodsAllowed(resources, req); DocumentBuilder documentBuilder = getDocumentBuilder(); try {

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

log("Delete:" + path); if (isSpecialPath(path)) { errorList.put(path, Integer.valueOf(WebdavStatus.SC_FORBIDDEN)); return; childName += entry; if (isLocked(childName, ifHeader + lockTokenHeader)) { WebResource childResource = resources.getResource(childName); if (childResource.isDirectory()) { deleteCollection(req, childName, errorList);

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

lockTokenHeader = ""; if (isLocked(path, ifHeader + lockTokenHeader)) { resp.sendError(WebdavStatus.SC_LOCKED); return false; new Hashtable(); deleteCollection(req, resources, path, errorList); try { resources.unbind(path); sendReport(req, resp, errorList); return false;

代码示例来源:origin: jboss.web/jbossweb

StringBuilder methodsAllowed = determineMethodsAllowed(resources, req); String path = getRelativePath(req); if (path.endsWith("/")) path = path.substring(0, path.length() - 1); DocumentBuilder documentBuilder = getDocumentBuilder(); generatedXML.writeElement (null, "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING); parseLockNullProperties (req, generatedXML, lockNullPath, type, properties); + generateNamespaceDeclarations(), XMLWriter.OPENING); parseProperties(req, generatedXML, path, type, properties); } else { parseProperties(req, generatedXML, currentPath, type, properties); String lockNullPath = lockNullResourcesList.nextElement();

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/** * Delete a resource. * * @param req Servlet request * @param resp Servlet response * @return boolean true if the copy is successful */ private boolean deleteResource(HttpServletRequest req, HttpServletResponse resp) throws IOException { String path = getRelativePath(req); return deleteResource(path, req, resp, true); }

代码示例来源:origin: org.jboss.web/jbossweb

/** * DELETE Method. */ protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } deleteResource(req, resp); }

代码示例来源:origin: jboss.web/jbossweb

log("Delete:" + path); childName += ncPair.getName(); if (isLocked(childName, ifHeader + lockTokenHeader)) { Object object = resources.lookup(childName); if (object instanceof DirContext) { deleteCollection(req, resources, childName, errorList);

内容来源于网络,如有侵权,请联系作者删除!

WebdavServlet 关注 举报


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有