You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Martin (Jira)" <ji...@apache.org> on 2025/05/07 20:47:00 UTC

[jira] [Updated] (WW-5548) Request attribute FORWARD_SERVLET_PATH incorrectly set by ServletDispatcherResult breaking sitemesh integration

     [ https://issues.apache.org/jira/browse/WW-5548?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin updated WW-5548:
-----------------------
    Description: 
The servlet request parameter FORWARD_SERVLET_PATH has the following documentation in tomcat: 

{noformat}
The name of the request attribute that should be set by the container when the forward(ServletRequest, ServletResponse) method is called. It provides the original value of a path-related property of the request. See the chapter "Forwarded Request Parameters" in the Servlet Specification for details.
{noformat}

Strut's org.apache.struts2.result.ServletDispatcherResult#doExecute method is breaking this spec in a couple of ways: 
 # it's setting the parameter to be the  path that the request is about to be _forwarded_ to, not the _original_ path.
 # it's setting the parameter itself, when that should be the responsibility of the container (in this case, Tomcat) when  forward() is invoked.

Documentation for FORWARD_SERVLET_PATH
https://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/RequestDispatcher.html#FORWARD_SERVLET_PATH

Tomcat container implementation of forward() which is responsible for setting the parameter
https://github.com/apache/tomcat/blob/99ebd1e375297ad02846322e85d533c61077a7dc/java/org/apache/catalina/core/ApplicationDispatcher.java#L241

This is breaking integration with other tools which expect the FORWARD_SERVLET_PATH to be set correctly, such as sitemesh (from version 3.1 onwards)

{code:xml}
<sitemesh>
    ....
    <mapping path="/auth/*.action" decorator="/WEB-INF/decorators/main.jsp"/>
    ....
</sitemesh>
{code}

Sitemesh now picks up the incorrectly set FORWARD_SERVLET_PATH which in my case is mapped to a JSP in struts.xml like so 

{code:xml}
<struts>
...
  <package name="authoritative links" extends="pkb-default" namespace="/auth" strict-method-invocation="true">

    <action name="dashboard" class="com.pkb.action.DashboardAction">
      <result name="success">/WEB-INF/view/dashboard.jsp</result>
    </action>
...
{code}

and my decorator is no longer applied, when it was previously.

This behaviour was introduced in https://issues.apache.org/jira/browse/WW-5463

  was:
The servlet request parameter FORWARD_SERVLET_PATH has the following documentation in tomcat: 

{noformat}
The name of the request attribute that should be set by the container when the forward(ServletRequest, ServletResponse) method is called. It provides the original value of a path-related property of the request. See the chapter "Forwarded Request Parameters" in the Servlet Specification for details.
{noformat}

Strut's org.apache.struts2.result.ServletDispatcherResult#doExecute method is breaking this spec in a couple of ways: 
 # it's setting the parameter to be the  path that the request is about to be _forwarded_ to, not the _original_ path.
 # it's setting the parameter itself, when that should be the responsibility of the container (in this case, Tomcat) when  forward() is invoked.

Documentation for FORWARD_SERVLET_PATH
https://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/RequestDispatcher.html#FORWARD_SERVLET_PATH

Tomcat container implementation of forward() which is responsible for setting the parameter
https://github.com/apache/tomcat/blob/99ebd1e375297ad02846322e85d533c61077a7dc/java/org/apache/catalina/core/ApplicationDispatcher.java#L241

This is breaking integration with other tools which expect the FORWARD_SERVLET_PATH to be set correctly, such as sitemesh (from version 3.1 onwards)

{code:xml}
<sitemesh>
    ....
    <mapping path="/auth/*.action" decorator="/WEB-INF/decorators/main.jsp"/>
    ....
</sitemesh>
{code}

Sitemesh now picks up the incorrectly set FORWARD_SERVLET_PATH which in my case is mapped to a JSP in struts.xml like so 

{code:xml}
<struts>
...
  <package name="authoritative links" extends="pkb-default" namespace="/auth" strict-method-invocation="true">

    <action name="dashboard" class="com.pkb.action.DashboardAction">
      <result name="success">/WEB-INF/view/dashboard.jsp</result>
    </action>
...
{code}

and my decorator is no longer applied, when it was previously.


> Request attribute FORWARD_SERVLET_PATH incorrectly set by ServletDispatcherResult breaking sitemesh integration
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-5548
>                 URL: https://issues.apache.org/jira/browse/WW-5548
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Dispatch Filter
>    Affects Versions: 7.0.0
>            Reporter: Martin
>            Priority: Major
>
> The servlet request parameter FORWARD_SERVLET_PATH has the following documentation in tomcat: 
> {noformat}
> The name of the request attribute that should be set by the container when the forward(ServletRequest, ServletResponse) method is called. It provides the original value of a path-related property of the request. See the chapter "Forwarded Request Parameters" in the Servlet Specification for details.
> {noformat}
> Strut's org.apache.struts2.result.ServletDispatcherResult#doExecute method is breaking this spec in a couple of ways: 
>  # it's setting the parameter to be the  path that the request is about to be _forwarded_ to, not the _original_ path.
>  # it's setting the parameter itself, when that should be the responsibility of the container (in this case, Tomcat) when  forward() is invoked.
> Documentation for FORWARD_SERVLET_PATH
> https://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/RequestDispatcher.html#FORWARD_SERVLET_PATH
> Tomcat container implementation of forward() which is responsible for setting the parameter
> https://github.com/apache/tomcat/blob/99ebd1e375297ad02846322e85d533c61077a7dc/java/org/apache/catalina/core/ApplicationDispatcher.java#L241
> This is breaking integration with other tools which expect the FORWARD_SERVLET_PATH to be set correctly, such as sitemesh (from version 3.1 onwards)
> {code:xml}
> <sitemesh>
>     ....
>     <mapping path="/auth/*.action" decorator="/WEB-INF/decorators/main.jsp"/>
>     ....
> </sitemesh>
> {code}
> Sitemesh now picks up the incorrectly set FORWARD_SERVLET_PATH which in my case is mapped to a JSP in struts.xml like so 
> {code:xml}
> <struts>
> ...
>   <package name="authoritative links" extends="pkb-default" namespace="/auth" strict-method-invocation="true">
>     <action name="dashboard" class="com.pkb.action.DashboardAction">
>       <result name="success">/WEB-INF/view/dashboard.jsp</result>
>     </action>
> ...
> {code}
> and my decorator is no longer applied, when it was previously.
> This behaviour was introduced in https://issues.apache.org/jira/browse/WW-5463



--
This message was sent by Atlassian Jira
(v8.20.10#820010)