JCharset with Tomcat 5.5

June 2, 2007

I use JCharset to get some additional character sets, including UTF 7 and GSM DEFAULT. While it was trivial to setup in development (where I launch Tomcat from an ant task with all sorts of parameters), it was a different story in production where I’m using the default Debian Etch install of Tomcat 5.5. It was very picky about where the JCharset.jar file went: it didn’t like in:

  • WEB-INF/lib
  • jre/lib (which has Sun’s charset.jar)
  • /var/lib/tomcat5.5/shared/lib

It has to go in:

/usr/share/tomcat5.5/endorsed

No errors or anything came up: it just didn’t load. I didn’t notice until I saw 404’s on the missing pages.


Custom java parameters for Tomcat on Debian Etch

May 14, 2007

The correct place for custom java parameters on Debian Etch is in /etc/default/tomcat5.5: look for the line:

CATALINA_OPTS=”-Djava.awt.headless=true -Xmx128M -server”

I usually bump up -Xmx (my server is just for Tomcat) and add -Xss2m.


Custom Server Header for Tomcat in Debian Etch

May 14, 2007

If you are using Tomcat to serve pages directly (i.e. not through Apache), it will send as server header of “ApacheCoyote/1.0 which I do not like. To change this, go into the /etc/tomcat5.5/server.xml file and in the appropriate tag, add an new attribute:

server=”NCSA/1.0a6″

Or whatever name you would like it to send. In the same spot, you can add the

URIEncoding=”UTF-8″

Which is necessary for full Unicode support.


Tomcat on port 80

April 7, 2007

I tried using rinetd to run Tomcat on port 80 but then you do not know the original ip address. Using iptables keeps the original IP address. The magic incantation that worked for me is (each should be a single line):

iptables -t nat -A OUTPUT -d localhost -p tcp –dport 80 -j REDIRECT –to-ports 8080iptables -t nat -A OUTPUT -d dotted.ip.address.here -p tcp –dport 80 -j REDIRECT –to-ports 8080

iptables -t nat -A PREROUTING -d dotted.ip.address.here -p tcp –dport 80 -j REDIRECT –to-ports 8080