Benny,
On 2/4/22 11:06, Benny Kannengießer wrote:
Thanks again Mark for the tip!
Like you suggested I wrapped the response, overriding "setStatus()" - but the method didn't get
called because the wrapper is not a subclass of the original response, it's just a façade. I think the
"setStatus()" method of the wrapped response (inner object) was called (by
"sendRerect())".
I'm not sure if it would be better if I used a dynamic proxy, not too much
experience with that...
I also tried overriding "sendRedirect()" on the wrapper, just setting the status to 301
and the location header to the location - and it worked! But I'm not sure,, somehow it feels wrong-
especially compared with the implementation of "sendRedirect()" in
org.apache.catalina.connector.Response which contains quiet some logic which I would circumvent.
What would be your opinion?
Ugly and working beats pretty and useless any day IMHO.
-chris
-----Ursprüngliche Nachricht-----
Von: Mark Thomas <ma...@apache.org>
Gesendet: Donnerstag, 3. Februar 2022 17:41
An: users@tomcat.apache.org
Betreff: Re: AW: Redirect with 301 for directory requested without trailing
slash
I didn't see a commit in the code but I didn't look into what
sendRedirect() does and I don't recall if there is a commit in there somewhere.
The other option would be the wrap the response in the Filter and override
setStatus() with something like:
@Override
public void setStatus(int status) {
if (status == 302) {
super.setStaus(301);
} else {
super.setStaus(status);
}
}
Completely untested - might not even compile - but you get the idea.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org