MessageBoard servlet 2.7


This is a Java servlet implements message board. Board supports e-mail notification and WAP/WML clients.

Each board supports file based persistence - your data will be saved in the flat file (files) or database based persistence. See below how to define this option.

How to use it:

a) copy messageBoardPackage.jar into your WEB-INF/lib directory.
b) define servlets in your web.xml file. There are two servlets: MessageBoard for board itself and AdminBoard for administration:
 

    <servlet>
     <servlet-name>MessageBoard</servlet-name>
     <servlet-class>com.jsos.mboard.MessageBoard</servlet-class>
    </servlet>

    <servlet>
     <servlet-name>AdminBoard</servlet-name>
     <servlet-class>com.jsos.mboard.AdminBoard</servlet-class>
    </servlet>


c) describe a mapping for servlets in web.xml file:
 

    <servlet-mapping>
     <servlet-name>MessageBoard</servlet-name>
     <url-pattern>/servlet/MessageBoard</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
     <servlet-name>AdminBoard</servlet-name>
     <url-pattern>/servlet/AdminBoard</url-pattern>
    </servlet-mapping>

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

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

http://your_host/servlet/MessageBoard?config_file

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

    <servlet>
     <servlet-name>MessageBoard</servlet-name>
     <servlet-class>com.jsos.mboard.MessageBoard</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/MessageBoard

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

    param=value

Empty lines and any line starts with # or // are ignored.

Current version supports the following list of parameters:

# 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

# Directory for uploaded files. If you set this parameter
# users will be able to add attachments to own messages
upload=any_existing_directory_on_your_server

# Interface

# board title (default value is empty - no title)
title=My Forum

# CSS Style (URL for your file)
css=path_to_your_css_file

# background (default value is #FFFFFF)
bgcolor=your_color

# foreground color (default value is #000000)
fgcolor=your_color

#
# You can use also different backgrounds for odd and even messages in the list
#
# odd messages background. Default value is #D6E6E1
odd=your_color

# even messages background. Default value is #F7F7F7
even=your_color

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

#font face (by default is current browser's font)
face=your_font_face

# 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

# sort titles (creation time): 1 - last to first, 0 - first to last (default value is 1)
sort=1

# sort messages (posting time): 1 - last to first, 0 - first to last (default value is 0)
sort1=0

# refresh time in seconds (default value is 600)
refresh=your_time

# enable/disable post messages. By default this parameter is empty
# and posting is enabled for everyone.
# You can provide here a commas separated list of roles for users allowed
# to post data
post=list_of_roles

# page size in messages (default value is 10)
page=8

# header. You can set here some file contains any html-code. This code will be
# outputted at the top for each page. So you can set for example some banners or CSS styles.
# By default this value is empty
header=path_to_your_file

# footer. You can set here some file contains any html-code. This code will be
# outputted at the bottom for each page.
# By default this value is empty
footer=path_to_your_file

# 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

# ask email: ask/do not ask email field for posted messages.
# Possible values are 1 (ask) or 0 (do not ask).
# Default value is 1. E.g.:
askemail=1

# ask URL: ask/do not ask URL field for posted messages.
# Possible values are 1 (ask) or 0 (do not ask).
# Default value is 1. E.g.:
askurl=1

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

# localization support. You can directly describe charset
# for output. By default servlet will use browser's settings.
# E.g. for chinese you may use this:
charset=Big5

#Password for administrator. Will be used in AdminBoard servlet.
# Default value is welcome
# admin=your_password

#
# you can set also smtp server parameters in case of you are going to use e-mail notification
#

# smtp port. By default is 25
port=25

# smtp host
host=your_mail_relay

# your mail domain
domain=your_domain

# from address. Address 'From' for notification letters
from=your_address

# to address. Notification will be emailed to any user
# who select 'Notify me' in the dialogue.
# But you can also send mail to specified address about
# any changes in board's data. This address is described as a 'to' parameter.
# (e.g. your administrator).
to=admin@yourcompany.com
 

You can save config file anywhere on your server. Just use the proper path for setting servlet's parameter. Short path (just name of the file) means that your configuration file is saved under servletrunner's root directory. But you can always use some like this:

http://your_host/servlet/MessageBoard?c:\myfiles\config.txt

or you may use a full path relatively to your root:

http://your_host/servlet/MessageBoard?/data/config.txt

Also the base directory for messages store can be created at the any place on your server (just check out access rights).

CSS settings

You can describe your own CSS styles for message board. Use the following classes:

message - CSS styles for textarea input
attribute - CSS styles for input text fields

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 calendars 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),
Moment CHAR(14),
Subject CHAR(80)
Author CHAR(255),
Email CHAR(80),
Url CHAR(80),
Attach CHAR(255),
Msg LONG VARCHAR
Notify CHAR(1));

You must use the same names for columns but depends on your database you can change the type for the 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.

Domain Moment will keep time stamp for messages (in milliseconds). We used type CHAR just for the compatibility with JDBC-ODBC bridges. You may also change types from CHAR to VARCHAR.

Note: evaluation version displays only first three pages for the each thread.

For downloading:   messageBoardPackage.jar   

Sample of config file: mbconf
 

 © Coldbeans     Comments?

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


     

Also in JSOS: