You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2023/11/06 08:47:34 UTC

(struts) branch feature/WW-5333-attribute-map updated (2e9eb4d8b -> edd3eb358)

This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a change to branch feature/WW-5333-attribute-map
in repository https://gitbox.apache.org/repos/asf/struts.git


    omit 2e9eb4d8b WW-5333 Refactors AttributeMap
     add 20eafb632 WW-5340 Mild refactor StrutsOgnlGuard for easier subclassing
     add 276ede4c8 WW-5340 Add debug logging for rejected form fields
     add f4029f8fd WW-5340 Sanitize field names before logging
     add fc03a2b69 Merge pull request #760 from apache/WW-5340-subclassable
     add 8a95a3f48 Bump ossf/scorecard-action from 2.2.0 to 2.3.0
     add a165c02ef Merge pull request #762 from apache/dependabot/github_actions/ossf/scorecard-action-2.3.0
     add 8ff8e42e7 Bump org.jfree:jfreechart from 1.5.1 to 1.5.4
     add 23feab685 Merge pull request #740 from apache/dependabot/maven/org.jfree-jfreechart-1.5.4
     add 4155263e6 WW-5349 Remove Struts core dependency on OGNL VarRefs
     add 6995eaf2f WW-5349 Remove corresponding unit tests
     add 913f6bf3a Merge pull request #763 from apache/WW-5349-astvarref
     add 62db310b0 Add JDK 21 build
     add 9c12bb86b Fix JDK 21 build
     add 00db84468 Convert test class to JUnit4
     add b736eb281 Upgrade EasyMock
     add f2834d252 Merge pull request #764 from apache/gh-actions-sonar-21
     add 0432205a6 WW-5354 Ensure ActionSupport fields are not parameter injectable
     add 67da669f0 Merge pull request #765 from apache/WW-5354-block-params
     add 39f81575f Upgrade Jackson and remove unnecessary transitive override
     add 403c3c4a1 Unify HtmlUnit versions
     add a750917fb Upgrade ASM and exclude conflicting artifact
     add 43fb80e17 Merge pull request #767 from apache/fix-conflict-deps
     add fb710f9ca Bump org.codehaus.mojo:versions-maven-plugin from 2.7 to 2.16.1
     add 84c1b1d0e Merge pull request #768 from apache/dependabot/maven/org.codehaus.mojo-versions-maven-plugin-2.16.1
     add 74d2fdcc6 WW-5355 Use LRU cache by default
     add 5011a7977 WW-5355 Prevent AtomicInteger being initialised to zero
     add 9527da5d3 WW-5355 Initial Caffeine cache implementation
     add 1573207ee WW-5355 Fix eviction limit in LRU cache not being enforced
     add 6ff7e15bf WW-5355 Update JavaDoc for basic and LRU cache
     add 9c932f203 WW-5355 Introduce new Struts constants and their defaults
     add bfb4df13e WW-5355 Unify bootstrap constant declaration
     add d245dc551 WW-5355 Introduce new cache type selection methods and deprecate problematic setter injection
     add 4700dca18 WW-5355 Downgrade Caffeine version
     add 7463e1de1 WW-5355 Fix interface and unit test bug
     add 28cc6459b WW-5355 Address code smells
     add 793d38371 WW-5355 Delegate deprecated constructor
     add 9be23d7a0 WW-5355 Extract constants into static final fields
     add 3d5beae36 WW-5355 Declare bootstrap constants as final field instead
     add f314b455f WW-5355 Add since tags to StrutsConstants JavaDoc
     add 9dbea66f9 WW-5355 Amend Caffeine cache implementation
     add 7cded18c0 WW-5355 Rename cache types
     add 7afc77266 WW-5355 Bootstrap using basic cache
     add cae627f35 Merge pull request #766 from apache/WW-5355-cache-lru
     add e8562c78d Bump org.owasp:dependency-check-maven from 7.2.0 to 8.4.2
     add fc5d1cabe Merge pull request #771 from apache/dependabot/maven/org.owasp-dependency-check-maven-8.4.2
     add 5bcf9e785 Improved charset retrieval to get only once.
     add afe31cc01 Update core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java
     add faa98d7af Update core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java
     add b15b83dd0 Merge pull request #773 from mygreen/improve-urldecoder-peformance
     add c2aec9c07 WW-5358 Expand exclusion lists
     add bd388956c Merge pull request #774 from apache/WW-5358-excl-list
     add 3ef0aa709 Bump ossf/scorecard-action from 2.3.0 to 2.3.1
     add 574da8111 Merge pull request #775 from apache/dependabot/github_actions/ossf/scorecard-action-2.3.1
     add f13284832 Bump junit:junit from 4.13.1 to 4.13.2
     add 48b0c1173 Merge pull request #776 from apache/dependabot/maven/junit-junit-4.13.2
     add 453130666 Bump org.jacoco:jacoco-maven-plugin from 0.8.8 to 0.8.11
     add 56fc1ddc5 Merge pull request #777 from apache/dependabot/maven/org.jacoco-jacoco-maven-plugin-0.8.11
     add 72d617012 Bump slf4j.version from 2.0.7 to 2.0.9
     add d8bc96d17 Merge pull request #783 from apache/dependabot/maven/slf4j.version-2.0.9
     add 601fb0ff5 Bump net.sf.jasperreports:jasperreports from 6.20.5 to 6.20.6
     add f511034ac Merge pull request #784 from apache/dependabot/maven/net.sf.jasperreports-jasperreports-6.20.6
     new edd3eb358 WW-5333 Refactors AttributeMap

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (2e9eb4d8b)
            \
             N -- N -- N   refs/heads/feature/WW-5333-attribute-map (edd3eb358)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/maven.yml                        |   2 +-
 .github/workflows/scorecards-analysis.yaml         |   2 +-
 apps/rest-showcase/pom.xml                         |   1 -
 apps/showcase/pom.xml                              |   1 -
 core/pom.xml                                       |   5 +
 .../xwork2/config/impl/DefaultConfiguration.java   |  31 +++++--
 .../xwork2/config/impl/MockConfiguration.java      |  18 +++-
 .../StrutsDefaultConfigurationProvider.java        |  15 ++-
 .../ognl/DefaultOgnlBeanInfoCacheFactory.java      |  19 ++--
 .../xwork2/ognl/DefaultOgnlCacheFactory.java       |  70 ++++++++++----
 .../ognl/DefaultOgnlExpressionCacheFactory.java    |  25 ++---
 .../opensymphony/xwork2/ognl/OgnlCacheFactory.java |  48 +++++++++-
 .../xwork2/ognl/OgnlCaffeineCache.java             |  78 ++++++++++++++++
 .../opensymphony/xwork2/ognl/OgnlDefaultCache.java |  27 +++---
 .../com/opensymphony/xwork2/ognl/OgnlLRUCache.java |  40 ++++----
 .../com/opensymphony/xwork2/ognl/OgnlUtil.java     |  65 +++++++------
 .../security/DefaultExcludedPatternsChecker.java   |  23 +----
 .../java/org/apache/struts2/StrutsConstants.java   |  57 ++++++------
 .../java/org/apache/struts2/components/UIBean.java |  12 ---
 .../multipart/JakartaMultiPartRequest.java         |  29 +++---
 .../org/apache/struts2/ognl/StrutsOgnlGuard.java   |  36 ++++---
 .../org/apache/struts2/url/StrutsUrlDecoder.java   |   5 +-
 .../org/apache/struts2/default.properties          |  38 +++-----
 .../src/main/resources/struts-excluded-classes.xml | 103 +++++++++++++--------
 .../xwork2/inject/ContainerImplTest.java           |  79 ++++++----------
 .../interceptor/ParametersInterceptorTest.java     |  16 +++-
 .../com/opensymphony/xwork2/ognl/OgnlUtilTest.java |  13 ++-
 .../org/apache/struts2/components/UIBeanTest.java  |  38 --------
 plugins/jasperreports/pom.xml                      |   2 +-
 plugins/jfreechart/pom.xml                         |   2 +-
 plugins/portlet/pom.xml                            |   9 --
 pom.xml                                            |  41 ++++----
 32 files changed, 555 insertions(+), 395 deletions(-)
 create mode 100644 core/src/main/java/com/opensymphony/xwork2/ognl/OgnlCaffeineCache.java


(struts) 01/01: WW-5333 Refactors AttributeMap

Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch feature/WW-5333-attribute-map
in repository https://gitbox.apache.org/repos/asf/struts.git

commit edd3eb358350f7964e8eea287ee486abe0f2f179
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Sat Nov 4 15:50:59 2023 +0100

    WW-5333 Refactors AttributeMap
---
 .../java/org/apache/struts2/components/Set.java    | 14 +++-----
 .../struts2/{util => dispatcher}/AttributeMap.java | 42 +++++++++++-----------
 .../org/apache/struts2/dispatcher/Dispatcher.java  | 11 +++---
 .../apache/struts2/dispatcher/DispatcherScope.java | 29 +++++++++++++++
 .../org/apache/struts2/dispatcher/RequestMap.java  |  4 +--
 .../debugging/DebuggingInterceptor.java            | 16 +++++----
 .../org/apache/struts2/views/jsp/TagUtils.java     |  2 +-
 .../org/apache/struts2/views/util/ContextUtil.java |  7 ++--
 .../portlet/dispatcher/Jsr168Dispatcher.java       | 13 +++----
 9 files changed, 84 insertions(+), 54 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/components/Set.java b/core/src/main/java/org/apache/struts2/components/Set.java
index 8cb1ca461..c045cd8cb 100644
--- a/core/src/main/java/org/apache/struts2/components/Set.java
+++ b/core/src/main/java/org/apache/struts2/components/Set.java
@@ -20,6 +20,7 @@ package org.apache.struts2.components;
 
 import java.io.Writer;
 
+import org.apache.struts2.dispatcher.DispatcherScope;
 import org.apache.struts2.views.annotations.StrutsTag;
 import org.apache.struts2.views.annotations.StrutsTagAttribute;
 
@@ -53,16 +54,11 @@ import com.opensymphony.xwork2.util.ValueStack;
  * <!-- START SNIPPET: params -->
  *
  * <ul>
- *
  * <li>var* (String): The name of the new variable that is assigned the value of <i>value</i></li>
- *
  * <li>value (Object): The value that is assigned to the variable named <i>name</i></li>
- *
  * <li>scope (String): The scope in which to assign the variable. Can be <b>application</b>, <b>session</b>,
  * <b>request</b>, <b>page</b>, or <b>action</b>. By default it is <b>action</b>.</li>
- * 
  * <li>Note: With the <b>action</b> scope, the variable is <em>also</em> assigned to the <b>page</b> scope.
- *
  * </ul>
  *
  * <!-- END SNIPPET: params -->
@@ -107,16 +103,16 @@ public class Set extends ContextBean {
 
         body="";
 
-        if ("application".equalsIgnoreCase(scope)) {
+        if (DispatcherScope.APPLICATION.equalsIgnoreCase(scope)) {
             stack.setValue("#application['" + getVar() + "']", o);
-        } else if ("session".equalsIgnoreCase(scope)) {
+        } else if (DispatcherScope.SESSION.equalsIgnoreCase(scope)) {
             stack.setValue("#session['" + getVar() + "']", o);
-        } else if ("request".equalsIgnoreCase(scope)) {
+        } else if (DispatcherScope.REQUEST.equalsIgnoreCase(scope)) {
             stack.setValue("#request['" + getVar() + "']", o);
         } else if ("page".equalsIgnoreCase(scope)) {
             stack.setValue("#attr['" + getVar() + "']", o, false);
         } else {
-            // Default scope is action.  Note: The action acope handling also adds the var to the page scope.
+            // Default scope is action. Note: The action scope handling also adds the var to the page scope.
             stack.getContext().put(getVar(), o);
             stack.setValue("#attr['" + getVar() + "']", o, false);
         }
diff --git a/core/src/main/java/org/apache/struts2/util/AttributeMap.java b/core/src/main/java/org/apache/struts2/dispatcher/AttributeMap.java
similarity index 75%
rename from core/src/main/java/org/apache/struts2/util/AttributeMap.java
rename to core/src/main/java/org/apache/struts2/dispatcher/AttributeMap.java
index ea088b4af..848b34aff 100644
--- a/core/src/main/java/org/apache/struts2/util/AttributeMap.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/AttributeMap.java
@@ -16,11 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.struts2.util;
+package org.apache.struts2.dispatcher;
 
 import org.apache.struts2.ServletActionContext;
 
 import javax.servlet.jsp.PageContext;
+import java.util.AbstractMap;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
@@ -38,17 +39,16 @@ import java.util.Set;
  *   <li>Session scope</li>
  *   <li>Application scope</li>
  * </ul>
- *
+ * <p>
  * A object is searched in the order above, starting from page and ending at application scope.
- *
  */
-public class AttributeMap implements Map {
+public class AttributeMap extends AbstractMap<String, Object> {
 
     protected static final String UNSUPPORTED = "method makes no sense for a simplified map";
 
-    Map context;
+    private final Map<String, Object> context;
 
-    public AttributeMap(Map context) {
+    public AttributeMap(Map<String, Object> context) {
         this.context = context;
     }
 
@@ -73,8 +73,8 @@ public class AttributeMap implements Map {
     }
 
     @Override
-    public Set entrySet() {
-        return Collections.EMPTY_SET;
+    public Set<Map.Entry<String, Object>> entrySet() {
+        return Collections.unmodifiableSet(this.context.entrySet());
     }
 
     @Override
@@ -82,9 +82,9 @@ public class AttributeMap implements Map {
         PageContext pc = getPageContext();
 
         if (pc == null) {
-            Map request = (Map) context.get("request");
-            Map session = (Map) context.get("session");
-            Map application = (Map) context.get("application");
+            RequestMap request = (RequestMap) context.get(DispatcherScope.REQUEST);
+            SessionMap session = (SessionMap) context.get(DispatcherScope.SESSION);
+            ApplicationMap application = (ApplicationMap) context.get(DispatcherScope.APPLICATION);
 
             if ((request != null) && (request.get(key) != null)) {
                 return request.get(key);
@@ -105,15 +105,15 @@ public class AttributeMap implements Map {
     }
 
     @Override
-    public Set keySet() {
-        return Collections.EMPTY_SET;
+    public Set<String> keySet() {
+        return Collections.unmodifiableSet(this.context.keySet());
     }
 
     @Override
-    public Object put(Object key, Object value) {
+    public Object put(String key, Object value) {
         PageContext pc = getPageContext();
         if (pc != null) {
-            pc.setAttribute(key.toString(), value);
+            pc.setAttribute(key, value);
         }
 
         return null;
@@ -135,8 +135,8 @@ public class AttributeMap implements Map {
     }
 
     @Override
-    public Collection values() {
-        return Collections.EMPTY_SET;
+    public Collection<Object> values() {
+        return Collections.unmodifiableCollection(this.context.values());
     }
 
     private PageContext getPageContext() {
@@ -146,10 +146,10 @@ public class AttributeMap implements Map {
     @Override
     public String toString() {
         return "AttributeMap {" +
-                "request=" + toStringSafe(context.get("request")) +
-                ", session=" +  toStringSafe(context.get("session")) +
-                ", application=" + toStringSafe(context.get("application")) +
-                '}';
+            "request=" + toStringSafe(context.get(DispatcherScope.REQUEST)) +
+            ", session=" + toStringSafe(context.get(DispatcherScope.SESSION)) +
+            ", application=" + toStringSafe(context.get(DispatcherScope.APPLICATION)) +
+            '}';
     }
 
     private String toStringSafe(Object obj) {
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 51ae95d27..aacddd18f 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -67,7 +67,6 @@ import org.apache.struts2.config.StrutsXmlConfigurationProvider;
 import org.apache.struts2.dispatcher.mapper.ActionMapping;
 import org.apache.struts2.dispatcher.multipart.MultiPartRequest;
 import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
-import org.apache.struts2.util.AttributeMap;
 import org.apache.struts2.util.ObjectFactoryDestroyable;
 import org.apache.struts2.util.fs.JBossFileManager;
 
@@ -779,14 +778,14 @@ public class Dispatcher {
             .withServletResponse(response)
             .withServletContext(servletContext)
             // helpers to get access to request/session/application scope
-            .with("request", requestMap)
-            .with("session", sessionMap)
-            .with("application", applicationMap)
-            .with("parameters", parameters)
+            .with(DispatcherScope.REQUEST, requestMap)
+            .with(DispatcherScope.SESSION, sessionMap)
+            .with(DispatcherScope.APPLICATION, applicationMap)
+            .with(DispatcherScope.PARAMETERS, parameters)
             .getContextMap();
 
         AttributeMap attrMap = new AttributeMap(extraContext);
-        extraContext.put("attr", attrMap);
+        extraContext.put(DispatcherScope.ATTRIBUTES, attrMap);
 
         return extraContext;
     }
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/DispatcherScope.java b/core/src/main/java/org/apache/struts2/dispatcher/DispatcherScope.java
new file mode 100644
index 000000000..2cceb892d
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/dispatcher/DispatcherScope.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.dispatcher;
+
+public interface DispatcherScope {
+
+    String REQUEST = "request";
+    String RESPONSE = "response";
+    String SESSION = "session";
+    String APPLICATION = "application";
+    String PARAMETERS = "parameters";
+    String ATTRIBUTES = "attr";
+}
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java b/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
index a75dffb75..b8e5b8e67 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
@@ -32,8 +32,9 @@ public class RequestMap extends AbstractMap<String, Object> implements Serializa
 
     private static final long serialVersionUID = -7675640869293787926L;
 
+    private final HttpServletRequest request;
+
     private Set<Entry<String, Object>> entries;
-    private HttpServletRequest request;
 
     /**
      * Saves the request to use as the backing for getting and setting values
@@ -44,7 +45,6 @@ public class RequestMap extends AbstractMap<String, Object> implements Serializa
         this.request = request;
     }
 
-
     /**
      * Removes all attributes from the request as well as clears entries in this map.
      */
diff --git a/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
index 62f871690..080b3136a 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/debugging/DebuggingInterceptor.java
@@ -29,8 +29,10 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.dispatcher.DispatcherScope;
 import org.apache.struts2.dispatcher.Parameter;
 import org.apache.struts2.dispatcher.PrepareOperations;
+import org.apache.struts2.dispatcher.RequestMap;
 import org.apache.struts2.views.freemarker.FreemarkerManager;
 import org.apache.struts2.views.freemarker.FreemarkerResult;
 
@@ -97,11 +99,13 @@ public class DebuggingInterceptor extends AbstractInterceptor {
 
     private final static Logger LOG = LogManager.getLogger(DebuggingInterceptor.class);
 
-    private String[] ignorePrefixes = new String[]{"org.apache.struts.",
-        "com.opensymphony.xwork2.", "xwork."};
-    private String[] _ignoreKeys = new String[]{"application", "session",
-        "parameters", "request"};
-    private HashSet<String> ignoreKeys = new HashSet<>(Arrays.asList(_ignoreKeys));
+    private final String[] ignorePrefixes = new String[]{"org.apache.struts.", "com.opensymphony.xwork2.", "xwork."};
+    private final HashSet<String> ignoreKeys = new HashSet<>(Arrays.asList(
+        DispatcherScope.APPLICATION,
+        DispatcherScope.SESSION,
+        DispatcherScope.PARAMETERS,
+        DispatcherScope.REQUEST
+    ));
 
     private final static String XML_MODE = "xml";
     private final static String CONSOLE_MODE = "console";
@@ -319,7 +323,7 @@ public class DebuggingInterceptor extends AbstractInterceptor {
             }
         }
         writer.endNode();
-        Map<String, Object> requestMap = (Map<String, Object>) ctx.get("request");
+        RequestMap requestMap = (RequestMap) ctx.get(DispatcherScope.REQUEST);
         serializeIt(requestMap, "request", writer, filterValueStack(requestMap));
         serializeIt(ctx.getSession(), "session", writer, new ArrayList<>());
 
diff --git a/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java b/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java
index f813e00d1..044f5d1af 100644
--- a/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java
+++ b/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java
@@ -24,7 +24,7 @@ import com.opensymphony.xwork2.util.ValueStack;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.util.AttributeMap;
+import org.apache.struts2.dispatcher.AttributeMap;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.jsp.PageContext;
diff --git a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
index 4ab3c2786..8a35c456f 100644
--- a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
+++ b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
@@ -20,6 +20,7 @@ package org.apache.struts2.views.util;
 
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.struts2.dispatcher.DispatcherScope;
 import org.apache.struts2.util.StrutsUtil;
 
 import javax.servlet.http.HttpServletRequest;
@@ -31,9 +32,9 @@ import java.util.Map;
  * Value Stack's Context related Utilities.
  */
 public class ContextUtil {
-    public static final String REQUEST = "request";
-    public static final String RESPONSE = "response";
-    public static final String SESSION = "session";
+    public static final String REQUEST = DispatcherScope.REQUEST;
+    public static final String RESPONSE = DispatcherScope.RESPONSE;
+    public static final String SESSION = DispatcherScope.SESSION;
     public static final String BASE = "base";
     public static final String STACK = "stack";
     public static final String STRUTS = "struts";
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
index cc7b00c5b..69e9b82e6 100644
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
+++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
@@ -33,6 +33,7 @@ import org.apache.struts2.StrutsException;
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.dispatcher.ApplicationMap;
 import org.apache.struts2.dispatcher.Dispatcher;
+import org.apache.struts2.dispatcher.DispatcherScope;
 import org.apache.struts2.dispatcher.HttpParameters;
 import org.apache.struts2.dispatcher.RequestMap;
 import org.apache.struts2.dispatcher.SessionMap;
@@ -48,7 +49,7 @@ import org.apache.struts2.portlet.context.PortletActionContext;
 import org.apache.struts2.portlet.servlet.PortletServletContext;
 import org.apache.struts2.portlet.servlet.PortletServletRequest;
 import org.apache.struts2.portlet.servlet.PortletServletResponse;
-import org.apache.struts2.util.AttributeMap;
+import org.apache.struts2.dispatcher.AttributeMap;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -377,7 +378,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
         container.inject(servletRequest);
 
         // ServletActionContext
-        Map<String, Object> extraContext = ActionContext.of(new HashMap<String, Object>())
+        Map<String, Object> extraContext = ActionContext.of(new HashMap<>())
             .withServletRequest(servletRequest)
             .withServletResponse(servletResponse)
             .withServletContext(servletContext)
@@ -392,10 +393,10 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
             .with(PORTLET_NAMESPACE, portletNamespace)
             .with(DEFAULT_ACTION_FOR_MODE, actionMap.get(request.getPortletMode()))
             // helpers to get access to request/session/application scope
-            .with("request", requestMap)
-            .with("session", sessionMap)
-            .with("application", applicationMap)
-            .with("parameters", parameterMap)
+            .with(DispatcherScope.REQUEST, requestMap)
+            .with(DispatcherScope.SESSION, sessionMap)
+            .with(DispatcherScope.APPLICATION, applicationMap)
+            .with(DispatcherScope.PARAMETERS, parameterMap)
             .with(MODE_NAMESPACE_MAP, modeMap)
             .with(PortletConstants.DEFAULT_ACTION_MAP, actionMap)
             .with(PortletConstants.PHASE, phase)