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/08/31 05:04:38 UTC

(struts) branch fix/WW-5450-forward created (now 16dac7b0b)

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

lukaszlenart pushed a change to branch fix/WW-5450-forward
in repository https://gitbox.apache.org/repos/asf/struts.git


      at 16dac7b0b WW-5450 Sets RequestDispatcher#FORWARD_REQUEST_URI attribute when forwarding

This branch includes the following new commits:

     new 16dac7b0b WW-5450 Sets RequestDispatcher#FORWARD_REQUEST_URI attribute when forwarding

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-5450 Sets RequestDispatcher#FORWARD_REQUEST_URI attribute when forwarding

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

lukaszlenart pushed a commit to branch fix/WW-5450-forward
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 16dac7b0b548935b57b3a7f4d8e1afc6fba8bc6c
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Sat Aug 31 07:04:24 2024 +0200

    WW-5450 Sets RequestDispatcher#FORWARD_REQUEST_URI attribute when forwarding
---
 .../main/java/org/apache/struts2/result/ServletDispatcherResult.java   | 3 +++
 .../java/org/apache/struts2/result/ServletDispatcherResultTest.java    | 1 +
 2 files changed, 4 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 df0896cf4..7de36e805 100644
--- a/core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java
+++ b/core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java
@@ -166,6 +166,9 @@ public class ServletDispatcherResult extends StrutsResultSupport {
                 request.setAttribute("struts.view_uri", finalLocation);
                 request.setAttribute("struts.request_uri", request.getRequestURI());
 
+                LOG.debug("Sets request attribute: {} to value: {}", RequestDispatcher.FORWARD_REQUEST_URI, finalLocation);
+                request.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI, finalLocation);
+
                 dispatcher.forward(request, response);
             } else {
                 LOG.debug("Including location: {}", finalLocation);
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 90da7b6c9..c1ab57b11 100644
--- a/core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java
+++ b/core/src/test/java/org/apache/struts2/result/ServletDispatcherResultTest.java
@@ -75,6 +75,7 @@ public class ServletDispatcherResultTest extends StrutsInternalTestCase implemen
         requestMock.expectAndReturn("getRequestDispatcher", C.args(C.eq("foo.jsp")), dispatcherMock.proxy());
         requestMock.expect("setAttribute", C.ANY_ARGS); // this is a bad mock, but it works
         requestMock.expect("setAttribute", C.ANY_ARGS); // this is a bad mock, but it works
+        requestMock.expect("setAttribute", C.args(C.eq(RequestDispatcher.FORWARD_REQUEST_URI), C.eq("foo.jsp")));
         requestMock.matchAndReturn("getRequestURI", "foo.jsp");
 
         Mock responseMock = new Mock(HttpServletResponse.class);