JSPs @ palmdrive

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:
  1. Emails are now written through a javascript function that should avoid them to be parsed by spam bots (spam bots are program that navigate through the web to fetch email addresses to be used for sending spam).
  2. 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!

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 "C:\gb\messages.txt", 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" %>
     <HTML>
     <HEAD>
     <TITLE>guest book</TITLE>
     </HEAD>
     <BODY>
     <%
       writeGuestBook(out,session,request);
     %>
     </BODY>
     </HTML>
  
Note: The guest book needs to know the URL used to access it. It does call request.getRequestURI() for this purpose. If you use any mechanism which change the URL mapping (such as struts), you can specify a name (relative or absolute) for the JSP to generate its own links. Instead of calling writeGuestBook(out,session,request), just call writeGuestBook(out,session,request,"foo.jsp"), foo.jsp being the name of the actual JSP requested by the browser.

Basic configuration

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 implementation, only "us" and "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.

Download

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!