X

Technology insights, news and tips.

  • Sun
    August 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.

Join the discussion

Comments ( 1 )
  • ias' me2DAY Friday, August 15, 2008
    [Trackback] WebDAV in GlassFish - WebDAV, 이제 좀 살아나는 거니?
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.