Thursday Aug 14, 2008

WEBDAV in GlassFish

WEBDAV (RFC 4918) protocol is a predecessor to HTTP/1.1 for management resources, etc. The WEBDAV code in GlassFish workspace is based on Tomcat. Jean-Francois blogged about this in 2006. WEBDAV Level 2 will be a supported feature in GlassFish v3. In this blog, we would provide additonal information about WEBDAV in GlassFish v3.

Configuration of WebDAVServlet

WEBDAV can be enabled by specifying the org.apache.catalina.servlets.WebdavServlet in web.xml for a given web application. Also, it can be enabled and configured globally in default-web.xml. One can configure WebDAVServlet by specifying the init-param as follows:

init-paramTypeDescriptionDefault
debugintdebug level0 (no debug)
listingsbooleanwhether one can list resourcesfalse
readonlybooleanwhether resources are readonlytrue

It is important to note that when listings is set to true or readonly is set to false, one must set up security constraints and turn on security manager.

WEBDAV Clients

I have verified that the following WEBDAV clients work with GlassFish v3:
  • Microsoft Word 2002 and 2003
      File > Open > the url
  • Internet Explorer 6 and 7
      File > Open (check "Open as Web Folder") > the url
    Note that under "Internet Options > Programs > HTML editor", we may like to set it to Microsoft Word above or Mircrosoft FrontPage.

Hand-On Examples on WEBDAV protocol

WEBDAV includes the following HTTP methods:
  • PROPFIND
  • PROPMATCH
  • MKCOL
  • GET
  • HEAD
  • POST
  • DELETE
  • PUT
  • COPY
  • MOVE
  • LOCK
  • UNLOCK
I find that it is a good exercise to send HTTP requests directly and see what happens there. For instance,
  • the following HTTP request copy index.html to index2.html:
    COPY /webdavtest/index.html HTTP/1.1
    Host: localhost
    Destination: http://localhost:8080/webdavtest/index2.html
    Connection: close
    
    
  • the following HTTP request delete the index2.html created above:
    DELETE /webdavtest/index2.html HTTP/1.1
    Host: localhost
    Connection: close
    
    
There are many ways to send http client requests to server. I find that it is quite handy to have the following Ruby script.


  #!/usr/bin/ruby
  
  require "socket"

  if ARGV.length != 3
      puts "ruby httpclient.rb <host> <port> <http request file>\\n"
      exit
  end

  host = ARGV[0];
  port = ARGV[1].to_i;
  filename = ARGV[2];

  socket = TCPSocket.open(host, port)

  file = File.new(filename)
  while line = file.gets
      command = line.chomp
      puts command + "\\r\\n"
      socket.write(command + "\\r\\n")
  end

  puts socket.readlines

  socket.close

Note that you may like to update the path of ruby or run the interpretator directly.

About

Shing Wai Chan

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today