On 26/06/17 11:22, Jérémie Barthés wrote:
> Thank for your  fast answer
> 
> I would like to extend DefaultServlet to override doDirectoryRedirect
> but the method is private,
> private void doDirectoryRedirect(HttpServletRequest request,
> HttpServletResponse response)
> 
> May this method be protected in following versions ?

Unlikely at this point.

> i can't change a header on the way out, after server started to answer,
> can i ?

Correct. The way to handle this is to wrap the response and intercept
the call that sets the location header and modify the value before
calling the wrapped response.

Mark


> 
> Regard
> 
> Jeremie
> 
> PS : i added a custom valve just to put non-rewritten URI in a request
> attribute, so i can use it if present when doDirectoryRedirect occurs
> 
> 
> Le 26/06/2017 à 12:01, Mark Thomas a écrit :
>> On 26/06/17 10:55, Jérémie Barthés wrote:
>>> Hi,
>>>
>>> I have an issue between org.apache.catalina.valves.rewrite.RewriteValve
>>> and org.apache.catalina.servlets.DefaultServlets
>>>
>>> If my request is forwarded by the RewriteValve and then pass into
>>> doDirectoryRedirect in DefaultServlets to be redirected. The hidden
>>> rewritten URI is displayed in the browser.
>>>
>>> To test it, try the following example (any tomcat 8, 8.5 or 9)
>>>
>>> add RewriteValve in conf/server.xml
>>> <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
>>>
>>> add rewriteRule in conf/Catalina/localhost/rewrite.config
>>> RewriteRule ^/iWantThisVisible/(.*) $/examples/$1/
>>>
>>> start tomcat
>>>
>>> go to following URLs (any internet browser) :
>>> http://localhost:8080/iWantThisVisible/servlets
>>> http://localhost:8080/iWantThisVisible/servlets/
>> That behaviour is expected.
>>
>> If you want to stick with the RewriteValve you'll need to write a custom
>> Valve or Filter to modify the HTTP headers on the way out.
>>
>> You might be better off writing a custom Servlet that does a forward.
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to