From cb505a85979fb735c7c37425ee4ca147d3ea8637 Mon Sep 17 00:00:00 2001
From: markt
Date: Sun, 6 Jun 2010 18:39:33 +0000
Subject: [PATCH] Part of refactoring STRICT_SERVLET_COMPLIANCE so it just
changes defaults New GET_RESOURCE_REQUIRE_SLASH property
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@951923 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/catalina/core/ApplicationContext.java | 22 ++++++++++++++++++++--
webapps/docs/config/systemprops.xml | 16 ++++++++++++----
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java
index d901b1a19..5610765a0 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -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);
diff --git a/webapps/docs/config/systemprops.xml b/webapps/docs/config/systemprops.xml
index 72a8c11b9..cbc894f67 100644
--- a/webapps/docs/config/systemprops.xml
+++ b/webapps/docs/config/systemprops.xml
@@ -229,12 +229,9 @@
request or response. (SRV.8.2 / SRV.14.2.5.1)
- ServletContext.getResource/getResourceAsStream must start with "/"
- if set to false, code like getResource("myfolder/myresource.txt") will work
-
-
The default value will be changed for:
+ rg.apache.catalina.core.ApplicationContext.GET_RESOURCE_REQUIRE_SLASH
org.apache.catalina.core.StandardHostValve.ACCESS_SESSION
org.apache.catalina.session.StandardSession.ACTIVITY_CHECK
org.apache.tomcat.util.http.ServerCookie.ALWAYS_ADD_EXPIRES.
@@ -274,6 +271,17 @@
true will be used.
+
+ If this is true then the path passed to
+ ServletContext.getResource() or
+ ServletContext.getResourceAsStream() must start with
+ "/". If false, code like
+ getResource("myfolder/myresource.txt") will work. If
+ org.apache.catalina.STRICT_SERVLET_COMPLIANCE is set to
+ true, the default of this setting will be true,
+ else the default value will be false.
+
+
If this is true Tomcat will allow =
--
2.11.0