Tomcat version: 8.5
OS: Win10, Linux

Hi,

I'm facing an issue with an application that is using path parameters
in conjunction with a RewriteValve.

I narrowed down the problem by using the sample application available
here:  https://tomcat.apache.org/tomcat-8.5-doc/appdev/sample/

Context
======

1) I modified the webapp sample.war by creating a sub directory
"subpath" where I copied the file hello.jsp

The servlet URL is :  http://127.0.0.1:8080/sample/subpath/hello.jsp

2) I modified the servlet with the following code

Request URI:          <%= request.getRequestURI() %>

3) I added a RewriteValve by making 2 changes in ROOT webapp
a) create context.xml in webapps\ROOT\META-INF with the following content

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="ROOT" path="/" reloadable="true" crossContext="true">
    <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
</Context>

b) create rewrite.config in  webapps\ROOT\WEB-INF with the following content

RewriteRule ^/foo/(.*) /sample/$1 [L]

NB: The base of the url is rewritten to "sample" when it is equals to "foo"


Description of the problem
====================

If the request is : http://127.0.0.1:8080/sample/subpath/hello.jsp
The servlet response is:
Request URI: /sample/subpath/hello.jsp

It is as expected. So far no problem.

If the request is :
http://127.0.0.1:8080/sample/subpath;pathparam=123/hello.jsp
The servlet response is:
Request URI: /sample/subpath;pathparam=123/hello.jsp

It is also as expected. Path params are displayed.

If the request is : http://127.0.0.1:8080/foo/subpath;pathparam1=123/hello.jsp
The servlet response is:
Request URI: /sample/subpath/hello.jsp

In this case, Tomcat stripped the path param. I was expecting it to be
maintained after the rewriting of the URL.

I would like to know if there is a way to preserve path parameters
from the URL after a rewrite or if it is a bug that I could report to
Bugzilla.

Feel free to ask me any question if it is not clear enough.

Thank you for your help.

Best regards
Alain

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to