First, I had to change the filter order of execution, so that the Jtidy filter will be called last (after the Struts filter has completed its work):
The new web.xml:
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts 2 Web Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter>
<filter-name>JTidyFilter</filter-name>
<filter-class>org.w3c.tidy.servlet.filter.JTidyFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>indent: auto; indent-spaces: 2; hide-comments: true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>JTidyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Second, I had to have on the classpath not only the jtidyservlet
jar, but also the jtidy
jar (without the latter, compilation went fine but I would get a java.lang.ClassNotFoundException: org.w3c.tidy.TidyMessageListener
in runtime).
in my pom.xml:
<dependency>
<groupId>jtidy</groupId>
<artifactId>jtidyservlet</artifactId>
<version>r8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>jtidy</artifactId>
<version>r8-21122004</version>
</dependency>
I also had to add the jtidyservlet
jar manually to my local maven repo:
Download
jtidyservlet-r8-SNAPSHOT.jar
from: http://jtidy.sourceforge.net/nightly/Drop it in
C:\TEMP
Run from command line:
SET LOCAL_JARS=C:\TEMP
mvn install:install-file -DgroupId=jtidy -DartifactId=jtidyservlet -Dversion=r8-SNAPSHOT -Dpackaging=jar -Dfile=%LOCAL_JARS%\jtidyservlet-r8-SNAPSHOT.jar -DgeneratePom=true