tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: How to stop trailing slash redirects?
Date Thu, 06 Jun 2019 11:28:42 GMT
чт, 6 июн. 2019 г. в 10:32, Rob Nikander <>:
> Hi,
> I would like requests to a webapp to have paths that look like this:
>     http://server/myapp <http://server/myapp>   not:  http://server/myapp/ <http://server/myapp/>
> But for some reason, Tomcat keeps redirecting the 1st to the 2nd. I’m aware of the
attribute `mapperContextRootRedirectEnabled` (on the Context), but setting that to “false”
is not helping.  My web.xml looks like:
>     <servlet-mapping>
>         <servlet-name>MyServlet</servlet-name>
>         <url-pattern></url-pattern>
>         <url-pattern>/other</url-pattern>
>         …
> What is going on? How do I stop the redirects?

1. Exact version number of Tomcat =? Does it support that attribute?

2. I think that you have to make your servlet the default one,
i.e. to map it to <url-pattern>/</url-pattern> just like it is done
with DefaultServlet in the default web.xml.

A filter can be mapped like that as well.

3. Beware that session cookies have "/" appended to their Path
attribute by default.

There is a Context attribute that configures that, but beware that
when a cookie path does not have the trailing '/', some browsers will
send this cookie both to myapp and to myappFoo (with any suffix).

In general, disabling the redirect is a bad idea and should be avoided.

Best regards,
Konstantin Kolinko

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message