About Tomcat and WebDAV

Source: Internet
Author: User
Tags ftp client

WebDAV is a communication protocol based on HTTP 1.1. It adds some extensions to HTTP 1.1 (that is, some new methods are added in addition to several HTTP standard methods such as GET, POST, and HEAD ), the application can directly write files to the Web Server, lock files when writing files, unlock files after writing, and support version control on files. The emergence of this protocol has greatly increased the value of Web as a creative media for us. Based on WebDAV, You can implement a powerful content management system or configuration management system.
I don't want to introduce the WebDAV protocol in detail here. If you are interested, find the relevant information here:
Http://www.webdav.org
First, you should read this WebDAV FAQ:
Http://www.webdav.org/other/faq.html
 
WebDAV is a communication protocol similar to HTTP (ietf rfc 2518 ). Similar to HTTP, it requires two software parts: server and client. Currently, WebDAV has a large number of related software implementations.
Here are some software projects related to WebDAV:
Http://www.webdav.org/projects/
 
Among these projects, we are most interested in open-source projects implemented in Java. Slide is one of the most important projects. Slide is a sub-project of the Jakarta Project (also Apache mountain). It provides a set of WebDAV server-side and client-side development libraries and APIs, and has now been released to version 2.0.
Http://jakarta.apache.org/slide/
Download the latest Slide 2.0 Binary package here.
Http://jakarta.apache.org/site/binindex.cgi
Slide is divided into two parts: server and client:
Server:
Http://apache.linuxforum.net/dist/jakarta/slide/binaries/jakarta-slide-server-bin-2.0.zip
Client:
Http://apache.linuxforum.net/dist/jakarta/slide/binaries/jakarta-slide-webdavclient-bin-2.0.zip
 
Let's talk about how to configure the server:
Decompress, assuming under D: \ tmp \ jakarta-slide-server-2.0, you will
D: \ tmp \ jakarta-slide-server-2.0 \ slide \ webapp \
Find two war files:
Slide. war: The Slide server configuration, which is implemented using Servlet.
Slide-doc.war: Slide document.
 
Copy the two war files to the deployment directory (generally webapps directory) of your Web Container (Tomcat, Jetty, Resin, etc.), and restart Web Container.
 
In the document I am writing, the server configuration is so simple.
 
Let's talk about how to configure it on the client.
WebDAV has many clients. Using the library of the Slide client, you can easily write a WebDAV client program. If you are interested, please refer to this document:
Http://www.onjava.com/lpt/a/4387
 
I will mainly talk about how to use the Web Folder feature provided by Windows 2000/XP to access Web folders.
After Windows 2000/XP is installed, you can access Web folders Based on the WebDAV protocol, map Web folders to a local folder, and support drag-and-drop, copy/paste, and other functions, it is very convenient to use.
To add a Web folder in Windows 2000/XP, follow these steps:
Open "Network neighbors", add network neighbors, and enter the URL of the Web folder in "Enter the location of network neighbors". For example, the WebDAV server configured with Slide is:
Http: // localhost: 8000/slide/
Then follow the wizard prompts to continue. It is very simple.
After configuration, you can use this Web folder as a local folder. Drag a few files and try again. For the preceding Web Folder configuration, refer to these documents:
Http://chapters.marssociety.org/webdav/
(A few documents written by cool, who are idle and tirelessly studying how humans migrate to Mars)
There are also related documents on the M $ Website:
Http://www.microsoft.com/windowsxp/home/using/productdoc/en/default.asp? Url =/windowsxp/home/using/productdoc/en/using_webfolders_for_file_transfer.asp
 
Many m$ products have built-in support for WebDAV. For example, Office 2000, IE 5/6, Exchange Server, and Frontpage. After configuring the WebDAV server, When I access this URL
Http: // localhost: 8000/slide/files/23.doc
Word 2000 can recognize that the Web server supports the WebDAV protocol. Therefore, Word 2000 can directly edit this document on the server and save it on the Web server after editing. Is this more convenient than downloading-> modify-> upload?
 
WebDAV has many other topics. For example, WebDAV can completely replace FTP. WebDAV has an overwhelming advantage over FTP in at least the following aspects:
1. You need to apply for an operating system account for FTP. WebDAV does not need to apply for any operating system account. It uses a set of secure and complete authentication mechanisms.
2. All FTP data (including logon information) is transmitted in plain text. Encryption must be implemented by yourself. For example, you can use GPG to do this manually, but it is inconvenient after all. WebDAV can be used to transmit data over HTTPS. encryption and decryption are completed automatically at the lower layer.
3. FTP data transmission efficiency is relatively low. A new TCP connection is required for each file to be transmitted, while WebDAV only needs one TCP connection for all files to be transmitted.
4. FTP is not as easy as HTTP to traverse the firewall, and its application scope in the Wan is much smaller than that in HTTP. Because WebDAV is based on HTTP, it has all the advantages of HTTP.
5. the FTP client tool does not have the WebDAV client tool for ease of use. You have seen that after the WebDAV server is configured, accessing the Web Folder in Windows 2000/XP Web Folder mode is not much different from accessing the local Folder. If the application supports the WebDAV protocol (for example, Word 2000), you can directly open and edit files in the Web folder and save them in the original Web folder. This is exactly the same as Samba. Do you know which FTP client is so convenient to use?
 
In addition to network neighbors, you can also directly open Web folders in IE. Run IE, "file-> open", and select "open as Web folder ". Enter
Http: // localhost: 8000/slide/
In this way, IE directly opens this Web Folder. You can drag a few files to try it. If it is a Word file, you can directly open and edit it with Word, and then save it directly on the Web Server. This is exactly the same as the effect of enabling it in the network neighbor.
You can write JS to directly open files in the Web folder, for example:
<Script language = "javascript">
<! --
Var word = new ActiveXObject ("Word. Application ");
Word. Visible = true;
Word. Documents. Open ("http: // localhost: 8000/slide/files/23.doc ");
// Word. Quit ();
-->
</Script>
Here is just an example of opening a Word file. You can also write examples of opening other types of files. The premise is that the applications of such files support the WebDAV protocol and provide corresponding controls that can be called by JS.
After the Word file is opened, it can be edited directly, and then saved directly on the Web Server, saving you the steps of download-> modify-> upload. Is it more convenient to use it?
 
By default, the WebDAV Server adds an exclusive write lock to the file when the client opens a file for the first time. In the future, all clients will read the file only. The lock is released only after the first client saves the file, and other clients can modify the file.
 
Slide can save files in the file system or in the database. Slide provides APIs that allow you to write plugin to save files to other types of storage systems.
Slide uses role-based permission control, and the role's permissions can be inherited. There is more to talk about these contents. If you are interested, you can refer to the Slide configuration document. The document also contains content related to version control.


This is an excerpt from a blog by yannanfeng.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.