KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jasper > runtime > HttpJspBase


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

17
18 package org.apache.jasper.runtime;
19
20 import java.io.IOException JavaDoc;
21
22 import javax.servlet.ServletConfig JavaDoc;
23 import javax.servlet.ServletException JavaDoc;
24 import javax.servlet.http.HttpServlet JavaDoc;
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26 import javax.servlet.http.HttpServletResponse JavaDoc;
27 import javax.servlet.jsp.HttpJspPage JavaDoc;
28 import javax.servlet.jsp.JspFactory JavaDoc;
29
30 import org.apache.jasper.compiler.Localizer;
31
32 /**
33  * This is the super class of all JSP-generated servlets.
34  *
35  * @author Anil K. Vijendran
36  */

37 public abstract class HttpJspBase
38     extends HttpServlet JavaDoc
39     implements HttpJspPage JavaDoc
40         
41     
42 {
43     
44     static {
45         if( JspFactory.getDefaultFactory() == null ) {
46             JspFactoryImpl factory = new JspFactoryImpl();
47             if( System.getSecurityManager() != null ) {
48                 String JavaDoc basePackage = "org.apache.jasper.";
49                 try {
50                     factory.getClass().getClassLoader().loadClass( basePackage +
51                                                                    "runtime.JspFactoryImpl$PrivilegedGetPageContext");
52                     factory.getClass().getClassLoader().loadClass( basePackage +
53                                                                    "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
54                     factory.getClass().getClassLoader().loadClass( basePackage +
55                                                                    "runtime.JspRuntimeLibrary");
56                     factory.getClass().getClassLoader().loadClass( basePackage +
57                                                                    "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
58                     factory.getClass().getClassLoader().loadClass( basePackage +
59                                                                    "runtime.ServletResponseWrapperInclude");
60                     factory.getClass().getClassLoader().loadClass( basePackage +
61                                                                    "servlet.JspServletWrapper");
62                 } catch (ClassNotFoundException JavaDoc ex) {
63                     org.apache.commons.logging.LogFactory.getLog( HttpJspBase.class )
64                         .error("Jasper JspRuntimeContext preload of class failed: " +
65                                        ex.getMessage(), ex);
66                 }
67             }
68             JspFactory.setDefaultFactory(factory);
69         }
70     }
71
72     protected HttpJspBase() {
73     }
74
75     public final void init(ServletConfig JavaDoc config)
76     throws ServletException JavaDoc
77     {
78         super.init(config);
79     jspInit();
80         _jspInit();
81     }
82     
83     public String JavaDoc getServletInfo() {
84     return Localizer.getMessage("jsp.engine.info");
85     }
86
87     public final void destroy() {
88     jspDestroy();
89     _jspDestroy();
90     }
91
92     /**
93      * Entry point into service.
94      */

95     public final void service(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
96     throws ServletException JavaDoc, IOException JavaDoc
97     {
98         _jspService(request, response);
99     }
100     
101     public void jspInit() {
102     }
103
104     public void _jspInit() {
105     }
106
107     public void jspDestroy() {
108     }
109
110     protected void _jspDestroy() {
111     }
112
113     public abstract void _jspService(HttpServletRequest JavaDoc request,
114                      HttpServletResponse JavaDoc response)
115     throws ServletException JavaDoc, IOException JavaDoc;
116 }
117
Popular Tags