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 2024/11/15 07:45:51 UTC
(struts) branch feature/WW-5463-servlet-path created (now c4007acbf)
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a change to branch feature/WW-5463-servlet-path
in repository https://gitbox.apache.org/repos/asf/struts.git
at c4007acbf WW-5463 Exposes final location as request attribute FORWARD_SERVLET_PATH
This branch includes the following new commits:
new c4007acbf WW-5463 Exposes final location as request attribute FORWARD_SERVLET_PATH
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.
(struts) 01/01: WW-5463 Exposes final location as request attribute FORWARD_SERVLET_PATH
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-5463-servlet-path
in repository https://gitbox.apache.org/repos/asf/struts.git
commit c4007acbffad30e2a0aa117848cb2ea5ac12babe
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Fri Nov 15 08:45:35 2024 +0100
WW-5463 Exposes final location as request attribute FORWARD_SERVLET_PATH
---
.../main/java/org/apache/struts2/result/ServletDispatcherResult.java | 3 +++
.../java/org/apache/struts2/result/ServletDispatcherResultTest.java | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java b/core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java
index d50ebadf5..5e906d7d1 100644
--- a/core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java
+++ b/core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java
@@ -158,6 +158,9 @@ public class ServletDispatcherResult extends StrutsResultSupport {
//if we are inside an action tag, we always need to do an include
boolean insideActionTag = (Boolean) ObjectUtils.defaultIfNull(request.getAttribute(StrutsStatics.STRUTS_ACTION_TAG_INVOCATION), Boolean.FALSE);
+ // this should allow integration with third-party view related frameworks
+ request.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, finalLocation.substring(0, finalLocation.indexOf('?')));
+
// If we're included, then include the view
// Otherwise do forward
// This allow the page to, for example, set content type
diff --git a/core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java b/core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java
index 2947e71e5..c64c9d76a 100644
--- a/core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java
+++ b/core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.struts2.result;
+import jakarta.servlet.RequestDispatcher;
import org.apache.struts2.ActionContext;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.StrutsStatics;
@@ -47,6 +48,7 @@ public class ServletDispatcherResultTest extends StrutsInternalTestCase implemen
view.execute(invocation);
assertEquals("foo.jsp", response.getForwardedUrl());
+ assertEquals("foo.jsp", request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH));
}
public void testInclude() throws Exception {
@@ -60,6 +62,7 @@ public class ServletDispatcherResultTest extends StrutsInternalTestCase implemen
view.execute(invocation);
assertEquals("foo.jsp", response.getIncludedUrl());
+ assertEquals("foo.jsp", request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH));
}
public void testWithParameter() throws Exception {
@@ -73,6 +76,7 @@ public class ServletDispatcherResultTest extends StrutsInternalTestCase implemen
// See https://issues.apache.org/jira/browse/WW-5486
assertEquals("1", stack.findString("#parameters.bar"));
+ assertEquals("foo.jsp", request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH));
}
@Override