KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibm > webdav > protocol > http > HeadMethod


1 package com.ibm.webdav.protocol.http;
2
3 /*
4  * (C) Copyright IBM Corp. 2000 All rights reserved.
5  *
6  * The program is provided "AS IS" without any warranty express or
7  * implied, including the warranty of non-infringement and the implied
8  * warranties of merchantibility and fitness for a particular purpose.
9  * IBM will not be liable for any damages suffered by you as a result
10  * of using the Program. In no event will IBM be liable for any
11  * special, indirect or consequential damages or lost profits even if
12  * IBM has been advised of the possibility of their occurrence. IBM
13  * will not be liable for any third party claims against you.
14  *
15  * Portions Copyright (C) Simulacra Media Ltd, 2004.
16  */

17 import java.util.logging.*;
18
19 import javax.servlet.http.*;
20
21 import com.ibm.webdav.*;
22
23 /** Executes the WebDAV HEAD method.
24  * @author Jim Amsden <jamsden@us.ibm.com>
25  */

26 public class HeadMethod extends WebDAVMethod
27 {
28     
29     private static Logger m_logger = Logger.getLogger(HeadMethod.class.getName());
30
31 /** Construct a HeadMethod.
32 * @param request the servlet request
33 * @param response the servlet response
34 * @exception com.ibm.webdav.WebDAVException
35 */

36 public HeadMethod(HttpServletRequest request, HttpServletResponse response) throws WebDAVException {
37     super(request, response);
38     methodName = "HEAD";
39 }
40 /** Execute the method.
41 * @return the result status code
42 */

43 public WebDAVStatus execute() {
44     try {
45         resource.getMetaInformation(context);
46         // fill in any response headers here
47

48         // set the response headers and status code. This must
49
// be done before a byte is written to the output stream
50
// or the headers and status code will be lost
51
setStatusCode(WebDAVStatus.SC_OK);
52         setResponseHeaders();
53     } catch (WebDAVException exc) {
54         setStatusCode(exc.getStatusCode());
55     } catch (Exception JavaDoc exc) {
56         m_logger.log(Level.WARNING, exc.getMessage(), exc);
57         setStatusCode(WebDAVStatus.SC_INTERNAL_SERVER_ERROR);
58     }
59     return context.getStatusCode();
60 }
61 }
62
Popular Tags