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


##########
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());
+                request.setAttribute(RequestDispatcher.FORWARD_PATH_INFO, 
request.getPathInfo());
+                request.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING, 
request.getQueryString());
+
                 dispatcher.forward(request, response);
             } else {
                 LOG.debug("Including location: {}", finalLocation);
+
+                // These attributes are required when forwarding to another 
servlet, see specification:

Review Comment:
   The comment in the include block is misleading; update 'forwarding to 
another servlet' to 'including another resource' for clarity.
   ```suggestion
                   // These attributes are required when including another 
resource, see specification:
   ```



-- 
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