01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 org.directwebremoting.servlet;
17:
18: import java.io.IOException;
19: import java.io.PrintWriter;
20:
21: import javax.servlet.http.HttpServletRequest;
22: import javax.servlet.http.HttpServletResponse;
23:
24: import org.directwebremoting.extend.DebugPageGenerator;
25: import org.directwebremoting.extend.Handler;
26: import org.directwebremoting.util.MimeConstants;
27:
28: /**
29: * A handler for requests to create a debug index page
30: * @author Joe Walker [joe at getahead dot ltd dot uk]
31: */
32: public class IndexHandler implements Handler {
33: /* (non-Javadoc)
34: * @see org.directwebremoting.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
35: */
36: public void handle(HttpServletRequest request,
37: HttpServletResponse response) throws IOException {
38: String page = debugPageGenerator.generateIndexPage(request
39: .getContextPath()
40: + request.getServletPath());
41:
42: response.setContentType(MimeConstants.MIME_HTML);
43: PrintWriter out = response.getWriter();
44: out.print(page);
45: }
46:
47: /**
48: * Setter for the debug page generator
49: * @param debugPageGenerator The new debug page generator
50: */
51: public void setDebugPageGenerator(
52: DebugPageGenerator debugPageGenerator) {
53: this .debugPageGenerator = debugPageGenerator;
54: }
55:
56: /**
57: * The bean to handle debug page requests
58: */
59: protected DebugPageGenerator debugPageGenerator = null;
60: }
|