If JTidy is really what you want, there is a Maven JTidy Plugin. It seems to work on files, not on URLs:
<build>
<plugins>
<plugin>
<groupId>jtidy</groupId>
<artifactId>maven-jtidy-plugin</artifactId>
<configuration>
<srcdir>src/main/resources/html</srcdir>
<destdir>target/html</destdir>
<properties>src/main/resources/jtidy.properties</properties>
</configuration>
<executions>
<execution>
<goals>
<goal>jtidy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Unless the plugin is not doing what you want, I wouldn't recommend using exec()
(which would need Tidy installed and thus harm portability).
(EDIT: Actually, I'm not sure of what you are trying to achieve exactly, if you want a fully automated solution or not, if you'll need to automate the deployment of application, etc, but here are some more hints.
For something manual, you could maybe use wget to save the generated HTML. For GET:
wget http://www.mypage.com/index.jsp?foo=bar
Or POST with the --post-data option:
wget http://www.mypage.com/index.jsp --post-data="foo=bar"
And then run JTidy.
If you want to automate things, you'll have to deploy your application first with the maven cargo plugin. Then, you could use the Ant's Get Task with the antrun plugin. And finally, perform the jtidy validation.
If you want to validate the generated HTML during the build, you'll need to deploy your application and to run some tool against it. You should look at the w3c-markup-validation-filter. Use the maven cargo plugin to deploy your application with the filter (cargo allows to merge web.xml
so you can add the filter only for the validation test) and run a set of basic selenium tests to browse your pages and check if the little box injected by the W3cMarkupValidationFilter into the HTML page is green.)