Home
english
Home
.NET Server
Java Server
.NET Client
AJAX Client
AJAX Browser
Map Drive
Pricing
Contacts
info@ithit.com



Creating Custom Method Handler

Custom method handler is required if you would like to replace original HTTP verb processing performed by WebDAV framework with your own processing or would like to process verbs that are not regulated by WebDAV standard.

Usually you will create a custom method handler for GET verb issued over WebDAV folder.

If user types WebDAV server url in a browser, the browser will submit GET request to a WebDAV folder. The WebDAV Engine will respond with 405, "Method Not Allowed" and user will see a blank page (in Firefox and Opera) or a "Method Not Allowed" page in Internet Explorer. To present any meaningful HTML page you have to create the page in GET handler:

MyWebDavEngine engine = new MyWebDavEngine();
CustomFolderGetHandler handler = new CustomFolderGetHandler();
handler.setPreviousHandler(engine.registerMethodHandler("GET", handler));
engine.service(httpServletRequest, httpServletResponse);

 

...

 

public class CustomFolderGetHandler implements MethodHandler {
    private MethodHandler previousHandler;

    public void processRequest(HttpServletRequest request, HttpServletResponse response, HierarchyItem item)
            throws DavException, IOException {

        if (item instanceof Folder) {
            response.getWriter().write("<HTML><BODY>");
            for (HierarchyItem child : ((Folder) item).getChildren())
                response.getWriter().format("<a href='%1s'>%2s</a><br/>", child.getPath(), child.getName());
            response.getWriter().write("</BODY></HTML>");
            response.getWriter().flush();
        } else {
            previousHandler.processRequest(request, response, item);
        }
    }

    public void setPreviousHandler(MethodHandler methodHandler) {
        previousHandler = methodHandler;
    }
}

To add or replace handler call Engine.registerMethodHandler method passing method name and object instance implementing MethodHandler interface prior to calling Engine.service method. The original handler, if any, is returned from registerMethodHandler method.

The MethodHandler.processRequest method is called by the engine during Engine.service call. The hierarchy item returned from Engine.getHierarchyItem is passed to processRequest method as a parameter.


What WebDAV software would you like to have?

Selected Customers:
Country: Norway
DnB NOR Group
Country: Finland
Bank of Finland
Country: United Kingdom
Bechtle Direct
Country: Sweden
BT Industries
Country: USA
California Chamber of Commerce
Country: Denmark
Danfoss Group
Country: Denmark
DFDS
Country: USA
Fluke Networks
Country: USA
HNI Corporation
Country: USA
IHS Inc
Country: USA
LandAmerica Financial Group
Country: Canada
Laurentian University
Country: USA
Microsoft
Country: Israel
RADVISION
Country: Ukraine
Raiffeisen Bank
Country: Netherlands
Sanoma Uitgevers
Country: USA
Siemens
Country: Australia
WorkCover NSW
Country: Ukraine
OTP Bank
Country: USA
Intel Corporation
Country: Austria
Austrian Federal Railways
Home .NET Server Java Server .NET Client AJAX Client AJAX Browser Map Drive Pricing Contacts

Updated: Tuesday, February 10, 2009