This Contributed Plugin allows you to execute JavaScript code on the server. Useful for creating pages with dynamic content. This plugin is stable but experimental; clearly better wiki integration and server safety issues need to be addressed.

Please note that installation and/or use of this feature on a public wiki is a security risk. This feature should only be used on a private or intranet wiki where the environment is entirely trusted.

The plugin's JavaScript implementation is Mozilla's Rhino. The public discussion for Mozilla's JavaScript implementations is at netscape.public.mozilla.jseng.

For more information please contact Andrew Gilmartin at


To built you will need to add the following libraries to the project's lib directory:

The plugin is available for

Then run ant.

The code does not yet conform to the JSPWiki Coding Standard.


Copy the file build/jspwiki-js-plugin.jar and lib/js.jar to JSPWiki's WEB-INF/lib directory.


The plugin is called using

[{com.ingenta.jspwiki.plugin.js.JSPlugin scriptPage='wikiPage' scriptResult='text|xml|wiki' }]

[{com.ingenta.jspwiki.plugin.js.JSPlugin script='javascript' scriptResult='text|xml|wiki' }]

[{com.ingenta.jspwiki.plugin.js.JSPlugin scriptResult='text|xml|wiki'

.. javascript body content ..

[{scriptPage scriptResult='text|xml|wiki'

.. data body content ..

For most installations you need only refer to the plugin as JSPlugin as the installation will have added com.ingenta.jspwiki.plugin.js to the jspwiki.plugin.searchPath property.

The script and scriptPage parameter or body content selects the JavaScript code to execute. The scriptResult parameter determines how the script's result is further processed; xml result output is sent as is to the browser; text result output is send to the browser after escaping &, <, >, and " characters; wiki result output is send to the browser after first converting to HTML. The default scriptResult value is wiki.

Using the scriptPage as the name of the plugin only works for JSPWiki implementations using the modified com.ecyrd.jspwiki.plugin.PluginManager supporting the jspwiki.plugin.unknownPlugin property. For more information see ScriptedPlugin.

During execution the following global variables are available to the script:

wikiInfo An instance of class JSWikiInfo
wikiPage An instance of class JSWikiPage for the page containing the plugin
pluginArgs An associative array containing the arguments to the plugin. For example format = pluginArgs[ "scriptResult" ];.
pluginBody The content of the plugin body. This is only set if the body does not contain the script.

See JSPluginScripts for examples of scripts.

Note that the current interpreter is not a safe one. Thus all event, file, socket, and use of Java classes is enabled.

Class and method detail#

class JSWikiPage# The name of the page. The author name of the most recient version.
o.created The creation date of the most recient version.
o.modified The last modified date of the most recient version.
o.versionNumber The version number of the most recient version.
o.versions Returns a list of page's versions. See JSWikiPageVersionInfo
o.attachments Returns a list of the page's attachments. See JSWikiPageAttachmentInfo
o.content Returns the content of the page.
o.setContent( pageContent ) Sets the content of the page (and creates a new version)

class JSWikiPageVersionInfo# The name of the author.
o.modified The last modified date.
o.versionNumber The version number.

class JSWikePageAttachmentInfo#

method description
o.fileName The attachment's file name.
o.fileSize The attachment's file size in bytes.

class JSWikiInfo#

method description
o.pluginVersion The version number of this plugin.
o.pages Returns a list of the pages.
o.hasPage( pageName ) Returns true if the named page exists.
o.getPage( pageName ) Returns the named page. It is an error if the page does not exist.
o.createPage( pageName, pageContent ) Creates a new page with the given name and content. It is an error if the page already exists.
o.deletePage( pageName ) Deletes the named page. It is an error if the page does not exist.

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
DO NOT USE.txt.txt 0.0 kB 1 16-Jan-2009 05:33 Andrew Gilmartin Depricated
browse.jsp 66.9 kB 1 04-Feb-2006 07:19
jspwiki-js-plugin-26Jul2006.ja... 13.5 kB 1 26-Jul-2006 22:47 Nascif Abousalh-Neto
jspwiki-js-plugin-jspwiki-2.8-... 25.0 kB 1 16-Jan-2009 05:21 Andrew Gilmartin Made "info" classes public to work with latest Java, JSPWiki, and Tomcat
jspwiki-js-plugin-src-26Jul200... 9.4 kB 1 26-Jul-2006 22:47 Nascif Abousalh-Neto
jspwiki-js-plugin.jar 13.2 kB 1 03-Mar-2005 23:46
jspwiki-js-plugin.tar.gz 6.0 kB 1 21-Feb-2005 21:39
« This page (revision-33) was last changed on 16-Jan-2009 22:07 by