Source code: org/apache/ajp/tomcat4/JkServlet.java
1 /*
2 * Copyright 1999-2004 The Apache Software Foundation
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
17 package org.apache.ajp.tomcat4;
18
19
20 import java.io.IOException;
21
22 import javax.servlet.ServletException;
23 import javax.servlet.http.HttpServlet;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26
27 import org.apache.catalina.Container;
28 import org.apache.catalina.ContainerServlet;
29 import org.apache.catalina.Context;
30 import org.apache.catalina.Wrapper;
31
32
33 /**
34 * Module loader for JkServlet
35 *
36 * @author Costin Manolache
37 */
38 public class JkServlet
39 extends HttpServlet implements ContainerServlet
40 {
41 // -------------------- ContainerServlet interface --------------------
42 Wrapper wrapper;
43
44 public Wrapper getWrapper() {
45 if( dL > 0 ) d("getWrapper()");
46 return wrapper;
47 }
48
49 public void setWrapper(Wrapper wrapper) {
50 if( dL > 0 ) d("setWrapper() " + wrapper );
51 this.wrapper=wrapper;
52 }
53
54 Context ctx;
55
56 /**
57 * Initialize this servlet.
58 */
59 public void init() throws ServletException {
60 super.init();
61 if(wrapper == null) {
62 log("No wrapper available, make sure the app is trusted");
63 //System.out.println("No wrapper available, make sure the app is trusted");
64 return;
65 }
66
67 ctx=(Context) wrapper.getParent();
68
69 if( dL > 0 ) {
70 d("Wrapper: " + wrapper.getClass().getName() + " " + wrapper );
71 d("Ctx: " + ctx.getClass().getName() + " " + ctx );
72 Object parent=ctx.getParent();
73 d("P: " + parent.getClass().getName() + " " + parent );
74 while( parent instanceof Container ) {
75 parent=((Container)parent).getParent();
76 d("P: " + parent.getClass().getName() + " " + parent );
77 }
78 }
79
80 }
81
82 public void service(HttpServletRequest request,
83 HttpServletResponse response)
84 throws IOException, ServletException
85 {
86 throw new ServletException("Shouldn't be called direclty");
87 }
88
89 private static final int dL=10;
90 private void d(String s ) {
91 log( "JkServlet: " + s );
92 }
93
94
95 }