The Guest Book©™®
The current release is 1.2, dated from Jan 28, 2006
Here is the version 1.1 page
Here is the version 1.0 page
The issues that have been adressed in 1.2 relates to spam:
- When posting, the program asks you to perform a small mathematical operation (here an addition). That is not much, but it should prevent robots from being able to post dummy entries in the guest book.
But there is always a great way for improvement.
What about a comment or suggestion of improvement? The only feedback is through...
the guest book
What is it ?
The guest book is a JSP that will allow any JSP-enabled webserver to operate a "guest book".
A guest book is a kind of simple forum where users can post messages. Messages are sorted by
date. Very primitive, but allow a form of interaction with your readers.
- Multi-lingual interface. Currently two languages are implemented: English and French.
Anybody can add a language very easily.
- Admin moderation support. The administrator can delete any message at
anytime through the web interface.
- Email notification support. Each time a user post a message in the guest book,
an email is sent to the administrator with the full content of the message. The admin
can immediately decide to let or remove the message. This feature is optional.
- Spam prevention on two levels: Need to perform an operation to post and
write emails in an obfuscated way.
- Safe Mode. This feature allow the administrator to prevent anybody from posting a message
that has not been reviewed first. Any user adding a message will be warned that his message
will appear on the site as soon as the admin has reviewed it. The new messages are hidden
from the users. The admin just have to log in to approve or delete new messages. This
feature is optional.
How to install
Nothing is simpler than that. Just download
the ZIP file and extract
the two files (guestBook.jsp, guestBook.css) in your webserver repository. You then just
need to specify where the guest book jsp should store the messages. Open guestBook.jsp in your
favorite text aditor and modify the line (on top of the JSP file):
public static final String PGB_FILE = "C:\\messages.txt";
To hold the file in which you want the guest book to store the messages. All the messages
are stored in a text file.
For example, if you want the guest book to store the messages in "
Just replace the above line with:
public static final String PGB_FILE = "C:\\gb\\messages.txt";
The last step is to create a JSP in which you will call the guestBook API. The simple JSP is listed below:
<%@ include file="guestBook.jsp" %>
The guest book needs to know the URL used to access it. It does call
for this purpose. If you use any mechanism which change the URL mapping (such as
), you can specify a name (relative or absolute) for the JSP
to generate its own links. Instead of calling
, just call
, foo.jsp being the name of the actual JSP requested
by the browser.
The configuration for the guestBook.jsp is included in the first lines of the file.
Just open the JSP in your favorite text editor and look at the first section. All
the attributes you can change are described below.
public static final String PGB_DEFAULT_LANG = "us";
This field indicates wether or not the user is going to look at the guest
book in english or french the first time he/she reach the page. In the current
"fr" languages are included
with the JSP.
public static final String PGB_DATE_FORMAT = "EEE, d MMM yyyy";
This field indicates the format the dates should be displayed on. The current
implementation uses a SimpleDateFormat class to do the formatting. Here is a
description of all the characters you can use in the PGB_DATE_FORMAT String:
Symbol Meaning Presentation Example
------ ------- ------------ -------
G era designator (Text) AD
y year (Number) 1996
M month in year (Text & Number) July & 07
d day in month (Number) 10
h hour in am/pm (1~12) (Number) 12
H hour in day (0~23) (Number) 0
m minute in hour (Number) 30
s second in minute (Number) 55
S millisecond (Number) 978
E day in week (Text) Tuesday
D day in year (Number) 189
F day of week in month (Number) 2 (2nd Wed in July)
w week in year (Number) 27
W week in month (Number) 2
a am/pm marker (Text) PM
k hour in day (1~24) (Number) 24
K hour in am/pm (0~11) (Number) 0
z time zone (Text) Pacific Standard Time
' escape for text (Delimiter)
'' single quote (Literal) '
Here are some examples of date format strings:
Format Pattern Result
"yyyy.MM.dd G 'at' hh:mm:ss z" ->> 1996.07.10 AD at 15:08:56 PDT
"EEE, MMM d, ''yy" ->> Wed, July 10, '96
"h:mm a" ->> 12:08 PM
"hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time
"K:mm a, z" ->> 0:00 PM, PST
"yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM
These examples were taken directly from the SimpleDateFormat javadoc.
This config should be moved soon in the language package.
public static final String PGB_ADMIN_EMAIL = null;
If ever there's a problem in the initialization of the Guest Book, an error
message will be displayed with this email as the person to contact. If null,
no email will be displayed.
public static final String PGB_ADMIN_PWD = "foo";
This defines the password for the administrator. Everyone that knows this password will be
able to delete any message from the guest book. In the safe mode (see below), this
password will also be used to approve new messages.
public static final String PGB_ADMIN_NOTIFICATION_EMAIL = null;
Each time someone leave a message in the guest book, an email will be sent to
this email address, notifying this person of the message being posted. If null,
no email message is being sent.
public static final String PGB_SMTP_SERVER = "my.smtp.server.net";
In order to be able to send email notifications, this variable must be set
to a valid smtp server name (or IP address). If null, no notification message
is being sent.
public static final String PGB_NOTIFICATION_EMAIL_SUBJECT = "New guest book entry";
This string represent the subject of the notification email. Usefull if you handle several
guest books and want to be able to distinguish between the two notification emails.
public static final boolean PGB_AUTO_APPROVE_MESSAGES = true;
If set to true, any message that is being submitted by a user will be visible by all the users.
If set to false, a user will not see his/her message until the admin did approve
it. This is what I call the "Safe Mode".
public static final int PGB_PAGE_SIZE = 10000;
This feature is not yet fully implemented, don't touch this parameter.
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... email@example.com
- 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
Download the Version 1.1 here
Download the Version 1.2 here
Beware! This file is so big (7kb) that it could
take up to 3 seconds with a 28.8 modem!