Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51220
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 19 May 2011 10:44:12 +0000 (10:44 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 19 May 2011 10:44:12 +0000 (10:44 +0000)
Add a system property to enable tag pooling with JSPs that use a custom base class.
Based on a patch by Dan Mikusa.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1124680 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/Generator.java
webapps/docs/changelog.xml
webapps/docs/config/systemprops.xml

index 4cec63c..4ffe988 100644 (file)
@@ -77,6 +77,8 @@ class Generator {
         System.getProperty("org.apache.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY", "_el_expressionfactory");
     private static final String VAR_INSTANCEMANAGER =
         System.getProperty("org.apache.jasper.compiler.Generator.VAR_INSTANCEMANAGER", "_jsp_instancemanager");
+    private static final boolean POOL_TAGS_WITH_EXTENDS =
+        Boolean.getBoolean("org.apache.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY");
 
     /* System property that controls if the requirement to have the object
      * used in jsp:getProperty action to be previously "introduced"
@@ -3423,7 +3425,7 @@ class Generator {
          * clarify whether containers can override init() and destroy(). For
          * now, we just disable tag pooling for pages that use "extends".
          */
-        if (pageInfo.getExtends(false) == null) {
+        if (pageInfo.getExtends(false) == null || POOL_TAGS_WITH_EXTENDS) {
             isPoolingEnabled = ctxt.getOptions().isPoolingEnabled();
         } else {
             isPoolingEnabled = false;
index 0f9e847..35520ba 100644 (file)
       </add>
     </changelog>
   </subsection>
+  <subsection name="Jasper">
+    <changelog>
+      <add>
+        <bug>51220</bug>: Add a system property to enable tag pooling with JSPs
+        that use a custom base class. Based on a patch by Dan Mikusa. (markt)
+      </add>
+    </changelog>
+  </subsection>
   <subsection name="Cluster">
     <changelog>
       <fix>
index 3167fbb..66e4b43 100644 (file)
 <section name="Jasper">
   <properties>
 
+    <property name="org.apache.jasper.compiler. Generator.POOL_TAGS_WITH_EXTENDS">
+      <p>By default, JSPs that use their own base class via the extends
+      attribute of the page directive, will have Tag pooling disabled since
+      Jasper cannot guarantee that the necessary initialisation will have taken
+      place. This can have a negative impact on performance. Providing the
+      alternative base class calls _jspInit() from Servlet.init(), setting  this
+      property to <code>true</code> will enable pooling with an alternative base
+      class. If the alternative base class does not call _jspInit() and this
+      property is <code>true</code>, NPEs will occur when attempting to use
+      tags.</p>
+      <p>If not specified, the default value of <code>false</code> will be used.
+      </p>
+    </property>
+
     <property name="org.apache.jasper.compiler. Generator.STRICT_GET_PROPERTY">
       <p>If <code>true</code>, the requirement to have the object referenced in
       <code>jsp:getProperty</code> action to be previously "introduced"