MFAshby commented on code in PR #1265:
URL: https://github.com/apache/struts/pull/1265#discussion_r2078993654


##########
core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java:
##########
@@ -173,9 +166,28 @@ public void doExecute(String finalLocation, 
ActionInvocation invocation) throws
                 request.setAttribute("struts.view_uri", finalLocation);
                 request.setAttribute("struts.request_uri", 
request.getRequestURI());
 
+                // These attributes are required when forwarding to another 
servlet, see specification:

Review Comment:
   I think setting these is the responsibility of the servlet container e.g. 
tomcat, inside the implementation of the `forward` method. We should not have 
to do it here at all.



##########
core/src/main/java/org/apache/struts2/result/ServletDispatcherResult.java:
##########
@@ -173,9 +166,28 @@ public void doExecute(String finalLocation, 
ActionInvocation invocation) throws
                 request.setAttribute("struts.view_uri", finalLocation);
                 request.setAttribute("struts.request_uri", 
request.getRequestURI());
 
+                // These attributes are required when forwarding to another 
servlet, see specification:
+                // 
https://jakarta.ee/specifications/servlet/6.0/jakarta-servlet-spec-6.0#forwarded-request-parameters
+                request.setAttribute(RequestDispatcher.FORWARD_MAPPING, 
request.getHttpServletMapping());
+                request.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI, 
request.getRequestURI());
+                request.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH, 
request.getContextPath());
+                request.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, 
request.getServletPath());

Review Comment:
   I think this is missing a guard to set the attribute only if it is not 
already set. There can be multiple forwards, and this attribute should contain 
the _original_ request as far as I understand. 
   
   Per the other comment I think this is redundant, the servlet container 
should be setting these properties and we should not touch them. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to