What is it ?
The fortune JSP is a piece of code that let you integrate fortune cookies into your JSP pages. No big deal. The only nice thing is that:
- You don't have to decode the fortune files. Just drop them in a specified directory and they are ready to be used.
- All UNIX Backspace combinations are replaced with their proper HTML equivalent, bringing to your page bold, underlined and accentuated text.
How to install
Nothing is simpler than that. Just download
the ZIP file and extract the file (fortune.jsp) in your webserver repository. You then just need to specify where the program should read all the fortune files. Open fortune.jsp in your favorite text aditor and modify the line (on top of the JSP file):
public static final String CFG_FILE = "C:\\fortune\\fortune.cfg";
To hold the file in which you will specify all your fortune files. This text file (fortune.cfg) must be present and contain the list of fortune files you want the JSP to choose from. It will look like:
If you want to use the four files
that are in the directory
You can download fortune files from many places, including but not limited to:
The last step is to create a JSP in which you will call the guestBook API. The simple JSP is listed below:
<%@ include file="fortune.jsp" %>
There is not much to configure. However, a couple of options can be used to help debug the product:
- Know which message is being displayed
You can easily display which message is being displayed by changing the last line of the fortune.jsp file:
<%= getFortuneMessage(request,false) %>
<%= getFortuneMessage(request,true) %>
. This will add a line on top of the fortune that looks like: 123/524. 123 is the number of the current fortune, 524 the total number of cookies to choose from.
- Display a specific fortune
You can display the first fortune, or the last or any number by adding
to your URL, where n
is the number of the cookie you want displayed. So let's say you want to see the fortune number 43, and your JSP is called
, just type in
Let's talk about some license here...
First of all, there is no such things as a license attached to this piece of code. Let's face it: Too simple to be licensed, right ?
of course, there's some stuff I would like
you to do if you ever decide to use my code...
- Just let me know about it... firstname.lastname@example.org
- Please leave a feedback with the strength/weaknesses of the product
- Please mention this site somewhere in your website
- If you ever do any modifications to the source code (Other than design/integration),
just let me know
It's up to you now guys.
Download the Version 1.0 here
Beware! This file is so big (3kb) that it could take up to 1.5 seconds with a 28.8 modem!