Versions :

Latest (most up to date )
Archive (previous versions)


This plugin will return a random single line from any designated Wiki page on each call. Thus each line of this page becomes a "fortune".


Please choose your plugin version:


This is the most up to date version of the plugin.

25-Sep-2008: FortuneCookiePlugin_v2.6.4.jar(info) package. source.
(Tested with JSPWiki 2.6.4 and Sun JDK 1.6.0)

Here are the changes:

  • Changed the plugin package and classname, it is now de.ldj.jspwiki.plugin.FortuneCookie
  • The fortunes will be cached and only reloaded if the fortunes page becomes modified. A count of fortunes as first line is no longer required/used.
  • Removed the usage of deprecated API. (I tested with JSPWiki v2.6.4 & JDK 1.6.0, but it should also work with later versions.)
  • Overall source cleanup. (see


Here you can find more recent versions of the plugin.

18-Mar-2005: FortuneCookiePluginv2.0.52.jar(info) package.
--MBarcia: (This plugin was not working for the 2.0.52 stable version. Also attached to this page is the JAR for this version. HTH)

05-Oct-2004: FortuneCookies.jar(info) package. source.
-- Bradford Holcombe: (I have added code to remove list wiki markup from each line. This allows the original page to use the wiki list syntax, so the fortune line looks better when rendered in its own page. Thanks to suggestions from Janne, I have added a call to the wiki tranlation engine so that each line (minus its original list markup) renders any wiki markup in the returned fortune. The new source is above, and the JAR reflects these changes.)


In order to use this plugin you need to:
  1. Download the plugin JAR
  2. Add the JAR to your JSPWiki classpath. (consult your ServletContainer manual how to do this)
  3. Prepare a WikiPage with fortunes. (see Fortune Format)
  4. Call the plugin at any WikiPage (except the one with the fortunes, this would cause an enless recursion)
    Depending on the version you choose, the call must be different:

The plugin requires the parameter 'page' to work. The value of page must be the name of an existing WikiPage. This page will be used as fortune page and must not contain a call to the FortuneCookiePlugin, because it might cause an endless recursion. Please find the format specification for the fortune page below.

Each caller must use the same WikiPage as fortune page!
The plugin behaviour is undefined if there are calls to different fortune pages.

Fortune Format#

The fortune cookie plugin uses one WikiPage as fortune source. Each line on this page will become considered a fortune.

The following formatting rules apply to the fortune page:

  • The fortune lines must be seperated by new-lines. Forced line breaks within the lines (\\) are not used as fortune delimeter. Thus it is possible to write multi-line fortunes.
  • The fortunes can be written as bulleted list (*), numbered list (#), with forced line breaks ('\\' followed by new-line) or as paragraphs (empty lines between each fortune). Even a mix is possible.
  • '*' or '#' at the begining of fortune lines will be removed before rendering the fortunes.
  • Fortunes with a forced line break at the end of their lines ('\\' followed by whitespace and a new-line) will be rendered without the trailing '\\'.
  • Regular Wiki markup can be used to style the fortunes.
  • Lines starting with '//' are considered as comment and will be ignored.

One last hint: If you want to emphasize your fortune cookies, so they look cool try to put the plugin inside a weblogcomments style block.
[{de.ldj.jspwiki.plugin.FortuneCookie page='FortuneCookies'}]

--Maik Scheibler, 25-Sep-2008 04:52


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 4.0 kB 1 25-Sep-2008 04:35 Maik Scheibler
java 3.2 kB 1 25-Sep-2008 14:02 Maik Scheibler moved source code from page to attachment
FortuneCookiePlugin_v2.6.4.jar 3.3 kB 1 25-Sep-2008 04:14 Maik Scheibler
FortuneCookiePluginv2.0.52.jar 2.3 kB 1 18-Mar-2005 22:41 Mbarcia
FortuneCookies.jar 3.1 kB 2 05-Oct-2004 18:27 BradfordHolcombe
« This page (revision-28) was last changed on 25-Sep-2008 16:02 by Maik Scheibler