Servlet to convert a JSPWiki HTML page into a clean HTML page.

The purpose of this servlet is to enable clean HTML output of a JSPWiki document. This resolves wrong formating of tables and other HTML content, usually entered by copying from external sources or from other plugins.


This servlet was compiled with Java version 1.6.0_17. Need this or above to run. You can also compile with your own version.

Tested with JSPWiki 2.8.1


page - The name of the page. Will be used as the HTML title.(Required)

tidy - Define the use of the HTML Tidy class for cleanup of the HTML code. Should be used for correct display; set to no only if you have problem with the encoding. Default value: yes. (Optional)

encoding - ID of the encoding to be used like UTF-8. If not set, default character set of the machine will be used. (Optional)


Copy wikicontent2html.jar(info) to /WEB-INF/lib of your JSPWiki installation.

Copy jtidy.jar, log4j.jar, xml-apis.jar to /WEB-INF/lib of your JSPWiki installation. See Dependencies section below for download links.

Should you choose to download a version from the external sites instead of using the attachemed file, make sure that the version dowloaded is the same or above the version attached.

Enter the following in the web.xml file:

Add the call to the servlet somewhere on your JSPWiki page, templates/default/Favorites.jsp is my preferred place, as it gives an option to the More... menu:
        <li><a class="action" 
                 href="<wiki:BaseURL/>wiki.html?page=<wiki:PageName />"
                 title="View as HTML">View as HTML

Create the file in /templates/ folder of the JSPWiki installation (if it does not already exists) and add the following content:
 actions.viewhtml=View Page HTML
 actions.viewhtml.title=View HTML


Dependencies needed for compilation of

j2ee.jar -> Java enterprise classes.
This can be found in the J2EE SDK (or tools that ship with it).
No need to install as the servlet container will have this,

JSPWiki.jar -> JSPWiki classes.
No need to install as this comes with the JSP Wiki.

jtidy.jar -> Tidy implementation for java.
Download from (latest version) or from the attached files (version 918)(info).

log4j.jar -> Apache Logging Services.
Download from (latest version) or from the attached files (version 1.2.14)(info).

xml-apis-xerces-2.9.1.jar -> XML parser.
Download from (latest version) or from the attached files (version 2.9.1)(info).

Known Issues:

In some browsers, you need to enable "Print background images" to print the page correctly.

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
java 11.5 kB 1 01-Dec-2009 12:05 Kyriakos Galatis Version 1 source code
jtidy.jar 187.7 kB 1 01-Dec-2009 11:54 Kyriakos Galatis JTidy library
log4j.jar 367.4 kB 1 01-Dec-2009 11:55 Kyriakos Galatis Apache Logging Services
wikicontent2html.jar 4.5 kB 1 01-Dec-2009 12:17 Kyriakos Galatis No dependencies
xml-apis-xerces-2.9.1.jar 194.4 kB 1 01-Dec-2009 11:55 Kyriakos Galatis XML Parser
« This page (revision-7) was last changed on 24-Aug-2010 15:41 by