2

I recently upgraded a project to Java 8, targeting Tomcat 9. It relies heavily on cookies that use commas and possibly spaces in the value so I need to use LegacyCookieProcessor because the cookies aren't RFC 6265 compliant. The only two ways I can find on how to do this require Spring Boot or editing context.xml in Tomcat. This project isn't using Spring Boot so the first one isn't an option, and I'd really rather not break portability by requiring context.xml to be changed wherever it is deployed.

Is it possible to configure this in Java config or web.xml (or any other way)?

secondbreakfast
  • 4,194
  • 5
  • 47
  • 101
  • 1
    from my understanding, tomcat supports per application config in [`/META-INF/context.xml`](https://tomcat.apache.org/tomcat-9.0-doc/config/context.html#Defining_a_context) bundled in the application package just like `web.xml` - and that file should support the cookie processor config. – zapl May 30 '18 at 13:48
  • 1
    @zapl Thank you, this worked. Feel free to post this solution as an answer and I will accept it. – secondbreakfast May 30 '18 at 19:47
  • Done. Feel free to edit the answer if you have anything useful to add / correct, I have never touched a tomcat config myself :) – zapl Jun 01 '18 at 14:05

1 Answers1

2

Tomcat supports per application config in /META-INF/context.xml bundled in the application package just like the web.xml file.

That file supports the cookie processor config

<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
zapl
  • 63,179
  • 10
  • 123
  • 154