1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts2.jasper.runtime;
19
20 import org.apache.struts2.jasper.compiler.Localizer;
21
22 import javax.servlet.ServletConfig;
23 import javax.servlet.ServletException;
24 import javax.servlet.http.HttpServlet;
25 import javax.servlet.http.HttpServletRequest;
26 import javax.servlet.http.HttpServletResponse;
27 import javax.servlet.jsp.HttpJspPage;
28 import javax.servlet.jsp.JspFactory;
29 import java.io.IOException;
30
31 /***
32 * This is the super class of all JSP-generated servlets.
33 *
34 * @author Anil K. Vijendran
35 */
36 public abstract class HttpJspBase
37 extends HttpServlet
38 implements HttpJspPage
39
40
41 {
42
43 static {
44 if (JspFactory.getDefaultFactory() == null) {
45 JspFactoryImpl factory = new JspFactoryImpl();
46 if (System.getSecurityManager() != null) {
47 String basePackage = "org.apache.struts2.jasper.";
48 try {
49 factory.getClass().getClassLoader().loadClass(basePackage +
50 "runtime.JspFactoryImpl$PrivilegedGetPageContext");
51 factory.getClass().getClassLoader().loadClass(basePackage +
52 "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
53 factory.getClass().getClassLoader().loadClass(basePackage +
54 "runtime.JspRuntimeLibrary");
55 factory.getClass().getClassLoader().loadClass(basePackage +
56 "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
57 factory.getClass().getClassLoader().loadClass(basePackage +
58 "runtime.ServletResponseWrapperInclude");
59 factory.getClass().getClassLoader().loadClass(basePackage +
60 "servlet.JspServletWrapper");
61 } catch (ClassNotFoundException ex) {
62 org.apache.commons.logging.LogFactory.getLog(HttpJspBase.class)
63 .error("Jasper JspRuntimeContext preload of class failed: " +
64 ex.getMessage(), ex);
65 }
66 }
67 JspFactory.setDefaultFactory(factory);
68 }
69 }
70
71 protected HttpJspBase() {
72 }
73
74 public final void init(ServletConfig config)
75 throws ServletException {
76 super.init(config);
77 jspInit();
78 _jspInit();
79 }
80
81 public String getServletInfo() {
82 return Localizer.getMessage("jsp.engine.info");
83 }
84
85 public final void destroy() {
86 jspDestroy();
87 _jspDestroy();
88 }
89
90 /***
91 * Entry point into service.
92 */
93 public final void service(HttpServletRequest request, HttpServletResponse response)
94 throws ServletException, IOException {
95 _jspService(request, response);
96 }
97
98 public void jspInit() {
99 }
100
101 public void _jspInit() {
102 }
103
104 public void jspDestroy() {
105 }
106
107 protected void _jspDestroy() {
108 }
109
110 public abstract void _jspService(HttpServletRequest request,
111 HttpServletResponse response)
112 throws ServletException, IOException;
113 }