How to use the "Set Character Encoding" filter in tomcat 4.0

X-Application Version: 3.1.2
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 4.0.2
JDK Version : 1.3.1

Hello,

Tomcat 4.0.2 does not support the DecodeInterceptor tag of tomcat 3.3 in the server.xml as described in X-Application´s installation documentation.

If you want to use tomcat 4.0.2 with X-Application 3.1.2 and you need to use the default UTF-8 encoding (or some other than iso8859-1) you could use a sample encoding filter of tomcat 4:

1. copy the class webapps\examples\WEB-INF\classes\filters\SetCharacterEncodingFilter.class to yourapp\WEB-INF\classes\filters\SetCharacterEncodingFilter.class
NOTE: respect the license conditions of apache in the corresponding java source file (same directory).

2. change your web.xml the following way:

code:
  
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
http://java.sun.com/dtd/web-app_2_3.dtd”>


DIAGNOSISfalse


CODEDtrue


TAMINO_URLhttp://yourserver/tamino/yourdb


TAMINO_COLLECTION1yourcollection


TAMINO_DOCTYPE1patient


Set Character Encoding
filters.SetCharacterEncodingFilter

encoding
UTF-8



Set Character Encoding
/*


404
/WEB-INF/jsp/xapplication.tld



Regards, Harald

I follows the instruction and test in Tomcat 4.0.3 and got the following errors in log file

2002-04-18 10:40:57 StandardManager[/abc]: Seeding random number generator class java.security.SecureRandom
2002-04-18 10:40:57 StandardManager[/abc]: Seeding of random number generator has been completed
2002-04-18 10:40:57 ContextConfig[/abc] Parse error in application web.xml
org.xml.sax.SAXParseException: Element type “filter” must be declared.
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.(Compiled Code)
at java.lang.Exception.(Compiled Code)
at org.xml.sax.SAXException.(SAXException.java:45)
at org.xml.sax.SAXParseException.(SAXParseException.java:56)
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213)
at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1807)
at org.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(Compiled Code)
at org.apache.xerces.validators.common.XMLValidator.callStartElement(Compiled Code)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(Compiled Code)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(Compiled Code)
at org.apache.xerces.framework.XMLParser.parse(Compiled Code)
at org.xml.sax.helpers.XMLReaderAdapter.parse(Compiled Code)
at javax.xml.parsers.SAXParser.parse(Compiled Code)
at javax.xml.parsers.SAXParser.parse(Compiled Code)
at org.apache.catalina.util.xml.XmlMapper.readXml(Compiled Code)
at org.apache.catalina.startup.ContextConfig.applicationConfig(ContextConfig.java:256)
at org.apache.catalina.startup.ContextConfig.start(Compiled Code)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:224)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Compiled Code)
at org.apache.catalina.core.ContainerBase.start(Compiled Code)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3345)
at org.apache.catalina.core.ContainerBase.addChild(Compiled Code)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:454)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployApps(Compiled Code)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:389)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:232)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Compiled Code)
at org.apache.catalina.core.ContainerBase.start(Compiled Code)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:614)
at org.apache.catalina.core.ContainerBase.start(Compiled Code)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:343)
at org.apache.catalina.core.StandardService.start(Compiled Code)
at org.apache.catalina.core.StandardServer.start(Compiled Code)
at org.apache.catalina.startup.Catalina.start(Catalina.java:781)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:681)
at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Compiled Code)
at org.apache.catalina.startup.Bootstrap.main(Compiled Code)

What can I do?

Dave Low

I got the solution.

Use the following dtd in web.xml

<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
Oracle Java Technologies | Oracle”>

Sorry for interruption!

Dave Low

Nice to see this problem solved :slight_smile:

I’d like to know which DTD you used initially?What caused the problem?
Because from reading you initial post I thought: maybe he used a 2.3 DTD and he should switch back
to 2.2. 2.2 is supposed to be the correct version of the DTD - when using Tomcat 3.3 and
Tomcat 4.0.

Michael

Software AG Germany, Darmstadt

I use version 2.2 DTD file at the beginning because it is generated by X-generator and runs on Tomcat 4.0.3

Dave Low