Skip to main content

Configuring URL Encoding on Tomcat Application Server

Application servers may have different settings for character encodings. We strongly recommend UTF-8 where possible.

By default, Tomcat uses ISO-8859-1 character encoding when decoding URLs received from a browser. This can cause problems when Confluence's encoding is UTF-8, and you are using international characters in the names of attachments or pages.

Tomcat

To configure the URL encoding in Tomcat:

Step 1 - Configure connector:
  1. Edit conf/server.xml and find the line where the Coyote HTTP Connector is defined. It will look something like this, possibly with more parameters:
    <Connector port="8080"/>
  2. Add a URIEncoding="UTF-8"property to the connector:
    <Connector port="8080" protocol="HTTP/1.1"
        connectionTimeout="20000"
        redirectPort="8443"
        URIEncoding="UTF-8"/>
  3. If you are using mod_jk you should apply the same URIEncoding parameter as above to the AJP connector if you are using mod_jk, and add the following option to your Apache mod_jk configuration:
   <Connector port="8009" protocol="AJP/1.3" URIEncoding="UTF-8"/>
    JkOptions +ForwardURICompatUnparsed



Step 2 - Add Encoding Filter:

The following filter settings need to be added  in  “web.xml” of {Tomcat_DIR}/conf folder:
  <!-- A filter that sets character encoding that is used to decode -->
  <!-- parameters in a POST request →

    <filter>
        <filter-name>setCharacterEncodingFilter</filter-name>
        <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <async-supported>true</async-supported>
    </filter>
   <filter>
      <filter-name>Set Character Encoding</filter-name>
      <filter-class>com.matrixone.servlet.SetCharacterEncodingFilter</filter-class>
      <init-param>
         <param-name>encoding</param-name>
         <param-value>UTF-8</param-value>
      </init-param>
   </filter>

    <filter-mapping>
        <filter-name>setCharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


Step 3 - Restart Tomcat.





Related Blogs:

How To Install Apache Tomcat on Ubuntu
Tomcat Clustering: Loadbalancing with mod_jk and Apache

 




Comments

Popular posts from this blog

JavaMelody: Monitoring the Performance of Tomcat Application Server

Javamelody is an opensource (LGPL) application to monitor Java or Java EE application servers in QA and production environments. JavaMelody is mainly based on statistics of requests and on evolution charts. (Extract from the Javamelody home page) It allows to improve applications in QA and production Give facts about the average response times and number of executions Make decisions when trends are bad, before problems become too serious Optimize based on the more limiting response times Find the root causes of response times Verify the real improvement after optimization It includes summary charts showing the evolution over time of the following indicators: Number of executions, mean execution times and percentage of errors of http requests, sql requests, jsp pages or methods of business façades (if EJB3, Spring or Guice) Java memory Java CPU Number of user sessions Number of jdbc connections These charts can be viewed on the current day, week, month, year or cu...

Java HotSpot VM Settings

The following JVM parameters are recommended: -Djava.awt.headless=true  -Dfile.encoding=UTF-8  -server  -Xms512m  -Xmx1024m  -XX:NewSize=256m  -XX:MaxNewSize=256m  -XX:PermSize=256m  -XX:MaxPermSize=256m  -XX:+DisableExplicitGC -Djava.awt.headless=true Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking. Sounds unexpected, but actually you can perform different operations in this mode, even with graphic data. -server The JDK includes two flavors of the VM -- a client-side offering, and a VM tuned for server applications. These two solutions share the Java HotSpot runtime environment code base, but use different compilers that are suited to the distinctly unique performance characteristics of clients and servers. These differences include the compilation inlining policy and heap defaults. Although the Server and the Client VMs are similar, the Serv...