Configuring Tomcat

After installation, you must update the default Tomcat configuration files with the appropriate settings.

About this task

UTF-8

By default, Tomcat assumes that requests are encoded with ISO-8859-1 instead of UTF-8. This default setting can break string handling if request parameters contained UTF-8 extended characters. For correct string handling, you must add the useBodyEncodingForURI="true" parameter to the <Connector> element of the server.xml configuration file.

POST Data limit

By default Tomcat limits POST data to 2 MB. This limit can cause an issue when you use rule sets, which can post data greater than this limit. To disable the POST limit in Tomcat, you can add the maxPostSize="-1" attribute to the <Connector> element of the server.xml configuration file.

Non-ASCII characters in Java source files

Tomcat converts JSPs into servlets that are contained in UTF-8 encoded Java sources files by default (for multi-byte character support). These files are generated into the work folder of the project. The Sysdeo plug-in marks the work folder as an Eclipse source folder. If you use the Eclipse build command, the Java compiler expects system encoding sources files by default. If any source file in the work folder contains non-ASCII characters, such as ú, an Invalid Character compiler error is generated and you cannot access the page in a web browser.

The keepgenerated attribute prevents Tomcat from saving the source files in the work folder and avoids this problem. You can prevent this occurring by updating the Tomcat web.xml configuration file with a new init-param element.

The Eclipse compiler cannot be changed to compile UTF-8 source files because of a second source folder that is called JavaSource that contains files that are not in UTF-8 encoding. Changing this setting does not affect the use of the application in any way. The keepgenerated parameter can be set to true if you want to view and debug through source files that are generated by Tomcat, but the error and browser access problem then occurs.

Procedure

  1. Edit the tomcat_install_dir\conf\server.xml configuration file and update the <Connector> element as follows.
    Where tomcat_install_dir\conf\server.xml is the directory where you installed Tomcat.
    1. Change the default port number to port="9080".
    2. Add the useBodyEncodingForURI="true" attribute.
    3. Optional: If you intend to use rule sets, add the maxPostSize="-1" attribute.
    For example:
    <Connector port="9080" maxThreads="150" minSpareThreads="25" 
    maxSpareThreads="75" enableLookups="false" redirectPort="8443" 
    acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" 
    useBodyEncodingForURI="true" maxPostSize="-1" />
  2. Edit the tomcat_install_dir\conf\context.xml configuration file. Update the <Context> element to include a reloadable="true" attribute.
    For example:
    <Context reloadable="true">
  3. Edit the tomcat_install_dir\conf\web.xml configuration file. Update the org.apache.jasper.servlet.JspServlet servlet with a new init-param element with the value false.
    For example:
    <init-param>
    <param-name>keepgenerated</param-name>
    <param-value>false</param-value>
    </init-param>