KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > servlet > DefaultServlet


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.webapp.servlet;
17
18 import javax.servlet.*;
19 import javax.servlet.http.HttpServlet JavaDoc;
20 import java.io.IOException JavaDoc;
21
22 /**
23  * <p>DefaultServlet to process static resources. ONLY FOR TOMCAT!!!</p>
24  * <p>This class is needed to allow filters to wrap requests for static resources in Tomcat</p>
25  * <p/>
26  * <p><a HREF="DefaultServlet.java.htm"><i>View Source</i></a></p>
27  *
28  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
29  * @version $Revision: 1.2 $ $Date: 2005/08/04 17:25:19 $
30  */

31 public class DefaultServlet extends HttpServlet JavaDoc {
32
33     /**
34      * The name of servlet which processes static resources in tomcat
35      */

36     protected static String JavaDoc DISPATCHER_NAME = "default";
37
38     protected ServletConfig config = null;
39
40     /**
41      * Initializes the servlet.
42      */

43     public void init(ServletConfig config) throws ServletException {
44         this.config = config;
45         super.init(config);
46     }
47
48     /**
49      * Destroys the servlet.
50      */

51     public void destroy() {
52         config = null;
53         super.destroy();
54     }
55
56     /**
57      * Dispatches client requests to the protected
58      * <code>service</code> method. There's no need to
59      * override this method.
60      *
61      * @param req the {@link javax.servlet.http.HttpServletRequest} object that
62      * contains the request the client made of
63      * the servlet
64      * @param res the {@link javax.servlet.http.HttpServletResponse} object that
65      * contains the response the servlet returns
66      * to the client
67      * @throws java.io.IOException if an input or output error occurs
68      * while the servlet is handling the
69      * HTTP request
70      * @throws javax.servlet.ServletException if the HTTP request cannot
71      * be handled
72      * @see javax.servlet.Servlet#service
73      */

74
75     public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException JavaDoc {
76         RequestDispatcher requestDispatcher = config.getServletContext().getNamedDispatcher(DISPATCHER_NAME);
77         requestDispatcher.forward(req, res);
78     }
79 }
Popular Tags