Part of refactoring STRICT_SERVLET_COMPLIANCE so it just changes defaults
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 6 Jun 2010 18:39:33 +0000 (18:39 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 6 Jun 2010 18:39:33 +0000 (18:39 +0000)
New GET_RESOURCE_REQUIRE_SLASH property

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

java/org/apache/catalina/core/ApplicationContext.java
webapps/docs/config/systemprops.xml

index d901b1a..5610765 100644 (file)
@@ -93,6 +93,24 @@ import org.apache.catalina.Globals;
 public class ApplicationContext
     implements ServletContext {
 
+    protected static final boolean STRICT_SERVLET_COMPLIANCE;
+
+    protected static final boolean GET_RESOURCE_REQUIRE_SLASH;
+
+
+    static {
+        STRICT_SERVLET_COMPLIANCE = Globals.STRICT_SERVLET_COMPLIANCE;
+        
+        String activityCheck = System.getProperty(
+                "org.apache.catalina.core.ApplicationContext.GET_RESOURCE_REQUIRE_SLASH");
+        if (activityCheck == null) {
+            GET_RESOURCE_REQUIRE_SLASH = STRICT_SERVLET_COMPLIANCE;
+        } else {
+            GET_RESOURCE_REQUIRE_SLASH =
+                Boolean.valueOf(activityCheck).booleanValue();
+        }
+    }
+
     // ----------------------------------------------------------- Constructors
 
 
@@ -497,7 +515,7 @@ public class ApplicationContext
         if (path == null)
             throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
 
-        if (!path.startsWith("/") && Globals.STRICT_SERVLET_COMPLIANCE)
+        if (!path.startsWith("/") && GET_RESOURCE_REQUIRE_SLASH)
             throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
 
         
@@ -541,7 +559,7 @@ public class ApplicationContext
         if (path == null)
             return (null);
 
-        if (!path.startsWith("/") && Globals.STRICT_SERVLET_COMPLIANCE)
+        if (!path.startsWith("/") && GET_RESOURCE_REQUIRE_SLASH)
             return null;
 
         String normalizedPath = RequestUtil.normalize(path);
index 72a8c11..cbc894f 100644 (file)
       request or response. (SRV.8.2 / SRV.14.2.5.1)
       </li>
       <li>
-        <code>ServletContext.getResource/getResourceAsStream</code> must start with "/"<br/>
-        if set to false, code like <code>getResource("myfolder/myresource.txt")</code> will work
-      </li>
-      <li>
         The default value will be changed for:
         <ul>
+        <li><code>rg.apache.catalina.core.ApplicationContext.GET_RESOURCE_REQUIRE_SLASH</code></li>
         <li><code>org.apache.catalina.core.StandardHostValve.ACCESS_SESSION</code></li>
         <li><code>org.apache.catalina.session.StandardSession.ACTIVITY_CHECK</code></li>
         <li><code>org.apache.tomcat.util.http.ServerCookie.ALWAYS_ADD_EXPIRES</code>.</li>
       <code>true</code> will be used.</p>
     </property>
 
+    <property name="org.apache.catalina.core. ApplicationContext.GET_RESOURCE_REQUIRE_SLASH">
+      <p>If this is <code>true</code> then the path passed to
+      <code>ServletContext.getResource()</code> or
+      <code>ServletContext.getResourceAsStream()</code> must start with
+      &quot;/&quot;. If <code>false</code>, code like
+      <code>getResource("myfolder/myresource.txt")</code> will work. If
+      <code>org.apache.catalina.STRICT_SERVLET_COMPLIANCE</code> is set to
+      <code>true</code>, the default of this setting will be <code>true</code>,
+      else the default value will be <code>false</code>.</p>
+    </property>
+
     <property
     name="org.apache.tomcat.util.http. ServerCookie.ALLOW_EQUALS_IN_VALUE">
       <p>If this is <code>true</code> Tomcat will allow <code>=</code>