Installation Guide

This package comes with pre-built binaries located in the dist directory. Those distribution files are:

jtidyservlet.jarthe taglib and servlet jar
jtidy-taglib-12.tldthe taglib tld file
jtidyservlet-webapp.wardocumentation and examples

To quickly view the documentation and examples showing the features and functionality of the JTidy servlet lib, just deploy the jtidyservlet-webapp.war file to your application server (the details of how differ from server to server). You could see this deployment here Live examples

If you would like to make use of the JTidy servlet lib in your own application, do the following:

STEP 1: Drop the jtidyservlet-{version}.jar file in your application WEB-INF/lib directory

STEP 2: Make sure that following libraries are in your WEB-INF/lib directory (or made available via the classpath to your application server). Refer to the runtime dependencies document for the correct version of these libraries. You can download a copy of everything from jakarta or you can grab them from the example webapp in the bin distribution.

  • commons-logging.jar
  • jtidy-r8.jar
  • xerces.jar
  • xml-apis.jar

STEP 3: Optional Configure new JTidyServlet in your web.xml. You need this to see the JTidy reports/(processing results and icons) in your web application. See STEP 5 - Security considerations before you make this changes on production system.


STEP 4: Select OPTION A if you will use tags or OPTION B if you will use Filter. It is also possible to use Filter and tags at the same time


If you are going to use tags for syntax checking and/or cleaning up generated HTML.

STEP A.1: Needed only for jsp 1.1 containers. Drop the jtidyservlet-{taglibversion}.tld file in your application WEB-INF/ directory. Refers to the tlds page for the available tlds.

STEP A.2: Needed only for jsp 1.1 containers. Define a taglib element like the following in your /WEB-INF/web.xml file


STEP A.3: Define the tag extension in each JSP page that uses the jtidy taglib or in commonly included JSP. The uri directives must match what you defined in the web.xml file above OR the URI defined in one of the tlds in the jar file. With jsp 1.2 containers the jar file is automatically scanned and you don't need to define any entry in your web.xml file. The prefix identifies the tags in the tag library within the JSP page.

<%@ taglib uri="" prefix="jtidy" %>

The declaration, if you are using a jsp xml sintax, looks like:

<jsp:root version="1.2" xmlns:jsp=""

Surround your complete html generation code with <jtidy:tidy> tag

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
  <title>My Page</title>
    My page body
        // Do anything


If you are going to use Filter for syntax checking and/or cleaning up generated or static HTML. This way you don't need to modify your JSP files.

STEP B.1: Configure the JTidyFilter in your web.xml:


And add mappings for the pages that you will intercept, for example:


DONE: During development you may include


inside common header JSP(Tile) to see immediately if the page you are manually testing is well formatted.

Page Validation OKNo problems
Page Validation WarningSome problems
Page Validation ErrorSerious errors
Page Validation OffJTidy did not processed this request

Also see examples there are many ways to do this. See Configuration for more details on how you could customize JTidyServelt for your application.

For more help with using taglibs in general, please see:

STEP 5: Security considerations

Default results Repository stores all generated HTML pages in memory and these pages are accessible to application end user via JTidyServlet. DefaultRepositoryFactory returns only one global instance of Repository. This may be convenient during application development but is not aceptable for production system.

For production you definitely need to disable HTML pages storage and use SessionRepositoryFactory. Example file is included in jtidyservlet.jar. As to me I'm not using JTidyServlet in production deployment because by the time of production I already fixed :) all errors in my application.