Search code examples
tomcat7url-encoding

Colon character : in the URL getting encoded in Tomcat 7.0.75


I recently upgraded Tomcat from v7.0.26 to v7.0.76 for one of my webapp. The URLs that were working earlier are not getting encoded. : gets encoded as %3A. I tried mentioning UTF-8 in the web.xml and server.xml, but the encoding is still seen. Has anyone come across a similar issue?


Solution

  • After investigating the tomcat changelog and trying several versions of tomcat, found that tomcat v7.0.70 has a change for this issue. The changeset is here. This change causes the URL to be encoded when you do a getRequestURI() call.

    To avoid this issue of encoding, we are using Tomcat version prior to 7.0.70.

    Alternatively there is a flag dispatchersUseEncodedPaths which can be used to enable/disable this encoding that was introduced in tomcat v7.0.70.