KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joseki > server > webserver > NotFoundHandler2


1 /** A handled for 404 NotFound replies in Jetty
2  * This one adds information like time and date.
3  */

4
5
6 // Original:
7
// ========================================================================
8
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
9
// ========================================================================
10

11 /* This version:
12  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
13  * [See end of file]
14  */

15
16 //package org.mortbay.http.handler;
17
package org.joseki.server.webserver;
18
19 import org.mortbay.http.* ;
20 import org.mortbay.http.handler.*;
21 //import org.mortbay.util.Code;
22
//import org.mortbay.util.StringUtil;
23

24 import java.io.* ;
25 import java.util.*;
26
27 /* ------------------------------------------------------------ */
28 /** Handler for resources that were not found.
29  * Implements OPTIONS and TRACE methods for the server.
30  * Was org.mortbay.http.handler.NotFoundHandler except I want the time/date as well
31  * because it helps debugging.
32  *
33  * @version $Id: NotFoundHandler2.java,v 1.3 2004/04/30 14:13:14 andy_seaborne Exp $
34  * @author Greg Wilkins (gregw)
35  */

36 public class NotFoundHandler2 extends NotFoundHandler
37 {
38     /* ------------------------------------------------------------ */
39     public void handle(String JavaDoc pathInContext,
40                        String JavaDoc pathParams,
41                        HttpRequest request,
42                        HttpResponse response)
43         throws HttpException, IOException
44     {
45         // Not found GET request
46
String JavaDoc method=request.getMethod();
47         if (method.equals(HttpRequest.__GET))
48         {
49             response.sendError(HttpResponse.__404_Not_Found,
50                                "Could not find resource for "+
51                                request.getPath()+" ("+new Date()+")");
52             return ;
53         }
54
55         super.handle(pathInContext, pathParams, request, response) ;
56     }
57 }
58
59 /*
60  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
61  * All rights reserved.
62  *
63  * Redistribution and use in source and binary forms, with or without
64  * modification, are permitted provided that the following conditions
65  * are met:
66  * 1. Redistributions of source code must retain the above copyright
67  * notice, this list of conditions and the following disclaimer.
68  * 2. Redistributions in binary form must reproduce the above copyright
69  * notice, this list of conditions and the following disclaimer in the
70  * documentation and/or other materials provided with the distribution.
71  * 3. The name of the author may not be used to endorse or promote products
72  * derived from this software without specific prior written permission.
73  *
74  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
75  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
76  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
77  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
78  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
79  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
80  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
81  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
82  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
83  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
84  */

85
Popular Tags