MailBoard servlet 2.4


What is this servlet for? From the one side it is a Java servlet implements classical message board. But from the another site it is a new concept. You do not need to go to particular web site for checking messages. The whole discussion will be locked within your mailbox. All what do you need is a mail clients supports HTML messages (most of them do this nowadays).

How does it work? With the help of this servlet you can start a new discussion. You type your message and mail it to the people you want to be joined to your discussion (including yourself). After that all what do you (and they) need is only check from time to time this letter from your (their) mailbox (mailboxes). Of course when you do that you must be online and MailBoard servlet (maintains all discussions) must be up.

The same servlet can serve many discussions and you can have different configurations for different discussions.

How to use it:

1. Download mailBoardPackage.jar and save it in your WEB-INF/lib folder.

2) Define servlet in your web.xml file.
 


    <servlet>
     <servlet-name>MailBoardServlet</servlet-name>
     <servlet-class>com.jsos.mailboard.MailBoardServlet</servlet-class>
    </servlet>

For each your board you must provide a configuration file describes how to save messages as well as various interface settings. You can use MailBoardServlet in two forms.

a) pass configuration file as a parameter. E.g.:
 


http://your_host/servlet/MailBoardServlet?config_file

b) define your configuration file as an initial parameter for servlet (parameter name is config):
 


    <servlet>
     <servlet-name>mailboard</servlet-name>
     <servlet-class>com.jsos.mailboard.MailBoardServlet</servlet-class>
     <init-param>
      <param-name>config</param-name>
      <param-value>path_to_your_configuration_file</param-value>
     </init-param>
    </servlet>

and use servlet in this form: http://your_host/servlet/mailboard

Configuration file is a text file, each line describes one parameter in the form of

    parameter=value

Empty lines and any line starts with # or // are ignored. Current version supports the following list of parameters:

# Persistence. You can use file based persistence -
# all data will be saved in the flat file (files)
# or database persistence.

# Base directory, this parameter must be set
# in case of file based persistence.
# Points to any existing directory on your server.
dir=your_directory

# JDBC settings. You must set this in case of db-based persistence
# Options are: (JDBC driver, database URL) pair or JNDI datasource
#
# JDBC driver
driver=your_jdbc_driver
# db URL
url=your_db_url

# JNDI name (instead of the above mentioned pair)
jndiname=your_data_source

# Optional parameter: user name for JDBC connection. You can omit this parameter.
user=db_user
# Optional parameter: password for JDBC connection. You can omit this parameter.
password=db_user's_password

# name of the table
table=your_db_table
# See below DDL description for this table

# Interface

# SMTP mail host. This parameter is mandatory
mailhost=relay.acme.com

# Mail domain. This parameter is mandatory
domain=acme.com

# SMTP port. Default value is 25
port=25

# address 'From'. Initial letter will be sended
# from this address. E.g.:
from=root@acme.com

# title. Default value is empty (no title)
title=My board title

# background color. Default value is  #FFFFFF  (white)
bgcolor=hexadecimal_color

#foreground color. Default value is #000000 (black)
fgcolor=your_color

#font size (by default is current browser's font)
size=2

#font face (by default is current browser's font)
face=Verdana,Arial

# space (empty lines) between threads. Default value is 0 (no space)
space=1

# Date format. By default board will use full date.
# You may set here your own format for date. E.g.:
date=dd/MM/yyyy hh:mm

# offset. By default board will use server's time (offset=0). You can
# set here time offset (+hours or -hours) if servlet is hosted in
# the another time zone.
offset=-3

# Sorting. How to output messages.
# 1 (default value) - display's data in the chronological order
# 2 - outputs the most recent messages at the first hand
sort=1

# Messages per page. Default value is 10 (One long thread will be always on the same page,
# regardless this setting).
page=10

# Frame to display messages. By default it is _self. In other
# words you will see messages in the same frame. You may
# keep messages tree in the one frame and display them in the another.
# E.g. frame=_blank - opens messages in the new window
frame=your_frame

# localization support. You can set character encoding for input parameters
# here. Default value is ISO-8859-1
encoding=Cp1251

Notes.
1. Configuration file can be saved anywhere on your server. In case of you are using MailBoard?file_name we assume that this file is saved under root directory of your servletrunner. But you can always use the full name for setting file location. E.g. you can type some like this:
http://your_host/servlet/MailBoard?c:\myfiles\myconfig.txt
or
http://your_host/servlet/MailBoard?/home/users/me/myconfig.txt

2. Evaluation version displays first three pages only.

More about database persistence

All data will be saved in the one table. Name of this table is included in your configuration file (table=your_table). So if you support several forums each of them has got own table (probably in the same database). Table must be created before the first use of servlet with the appropriate configuration file. Use your database admin tools for doing this. Here is a DDL statement for this table:
 


CREATE TABLE your_table_name (
Id CHAR(30) PRIMARY KEY,
Id1 CHAR(30),
Id2 CHAR(30),
Id3 CHAR(30),
Moment CHAR(14),
Author CHAR(80),
NrOfLines CHAR(6),
Subject CHAR(80),
Msg LONG VARCHAR);

You must use the same names for columns but depends on your database you can change the type for the last column (Msg). This column (domain) will keep text data for individual messages. You may decide to use TEXT for example. Check out your DB manual for supported SQL data types. You may also change types from CHAR to VARCHAR.

Initial dialog (screen).

This screen lets you start new discussion. You may replace it completely, or create discussions from your JSP/Perl/PHP script etc. In order to start a new discussion you have to post data to MailBoard servlet. Names for parameters (fields for HTML form) are: a2 - author, a3 - subject, a4 - message, a5 - "mail to" list. And action for HTML form is
http://your_host/servlet/MailBoard?config=your_config&act=nw
or
http://your_host/servlet/MailBoard?act=nw depends on the way you are using configuration file.

    For downloading:   mailBoardPackage.jar  
    Sample of configuration file:  mailboard

 © Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: