001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.jasper.runtime;
018:
019: import java.io.IOException;
020:
021: import javax.servlet.ServletConfig;
022: import javax.servlet.ServletException;
023: import javax.servlet.http.HttpServlet;
024: import javax.servlet.http.HttpServletRequest;
025: import javax.servlet.http.HttpServletResponse;
026: import javax.servlet.jsp.HttpJspPage;
027: import javax.servlet.jsp.JspFactory;
028:
029: import org.apache.jasper.compiler.Localizer;
030:
031: /**
032: * This is the super class of all JSP-generated servlets.
033: *
034: * @author Anil K. Vijendran
035: */
036: public abstract class HttpJspBase extends HttpServlet implements
037: HttpJspPage {
038: static {
039: if (JspFactory.getDefaultFactory() == null) {
040: JspFactoryImpl factory = new JspFactoryImpl();
041: if (System.getSecurityManager() != null) {
042: String basePackage = "org.apache.jasper.";
043: try {
044: factory
045: .getClass()
046: .getClassLoader()
047: .loadClass(
048: basePackage
049: + "runtime.JspFactoryImpl$PrivilegedGetPageContext");
050: factory
051: .getClass()
052: .getClassLoader()
053: .loadClass(
054: basePackage
055: + "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
056: factory.getClass().getClassLoader().loadClass(
057: basePackage + "runtime.JspRuntimeLibrary");
058: factory
059: .getClass()
060: .getClassLoader()
061: .loadClass(
062: basePackage
063: + "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
064: factory
065: .getClass()
066: .getClassLoader()
067: .loadClass(
068: basePackage
069: + "runtime.ServletResponseWrapperInclude");
070: factory.getClass().getClassLoader().loadClass(
071: basePackage + "servlet.JspServletWrapper");
072: } catch (ClassNotFoundException ex) {
073: System.out
074: .println("Jasper JspRuntimeContext preload of class failed: "
075: + ex.getMessage());
076: }
077: }
078: JspFactory.setDefaultFactory(factory);
079: }
080: }
081:
082: protected HttpJspBase() {
083: }
084:
085: public final void init(ServletConfig config)
086: throws ServletException {
087: super .init(config);
088: jspInit();
089: _jspInit();
090: }
091:
092: public String getServletInfo() {
093: return Localizer.getMessage("jsp.engine.info");
094: }
095:
096: public final void destroy() {
097: jspDestroy();
098: _jspDestroy();
099: }
100:
101: /**
102: * Entry point into service.
103: */
104: public final void service(HttpServletRequest request,
105: HttpServletResponse response) throws ServletException,
106: IOException {
107: _jspService(request, response);
108: }
109:
110: public void jspInit() {
111: }
112:
113: public void _jspInit() {
114: }
115:
116: public void jspDestroy() {
117: }
118:
119: protected void _jspDestroy() {
120: }
121:
122: public abstract void _jspService(HttpServletRequest request,
123: HttpServletResponse response) throws ServletException,
124: IOException;
125: }
|