WWWboard servlet 5.0

It is a Java servlet implements a classical message board. Board supports WAP/WML also. Servlet is fully configurable - you can even define your own labels (titles), e.g. translate interface to another language.

You can use boards with file based persistence - your data will be saved in the flat file (files) or database based persistence (through JDBC). See below how to define this option.

How to use it:

1) download wwwboardPackage.jar and save it in WEB-INF/lib

2) describe wwwboard servlet in web.xml file
 


    <servlet>
     <servlet-name>wwwboard</servlet-name>
     <servlet-class>com.jsos.wwwboard.wwwboardServlet</servlet-class>
    </servlet>

3) define a mapping:
 


    <servlet-mapping>
     <servlet-name>wwwboard</servlet-name>
     <url-pattern>/servlet/wwwboard</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 wwwboardServlet in two forms.

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


http://your_host/servlet/wwwboard?config_file

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


    <servlet>
     <servlet-name>wwwboard</servlet-name>
     <servlet-class>com.jsos.wwwboard.wwwboardServlet</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/wwwboard

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

# 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

# style. Describes a link for your CSS style file. By default is empty.
style=/css/board.css

# 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

# hr (horizontal line) between threads. Default value is empty (no line).
# Otherwise this parameter describes a CSS style for that line. E.g.:
hr=color:black

# 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

# header. You can set here some file contains any html-code. This code will be
# outputted at the beginning of the each page. So you can set for example some banners.
# 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 of the each page. So you can set for example some banners.
# By default this value is empty
footer=path_to_your_file

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

# IP address
# 1 - show the IP address for postings
# 0 (default value) - do not show IP
ip=1

# 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

# authorization flag (See Authorization section below)
authorized=attribute_name

# login page
login=your_page

# Messages per page. Default value is 20 (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

# Charset. You may describe exclusively charset for output pages.
# By default servlet does not define charset exclusively.
# E.g. for Chinese you may do so:
charset=Big5

# labels. You can define your own replacement for static HTML/WML labels.
# E.g. you can translate all static elements from English
# to your language
labels=full_path_to_the_translation_file

Authorization

You may incorporate this forum into your portal where your users will be authorized. In order to prevent access to this forum from not authorized visitors you may use authorized parameter in config file. Servlet assumes that your authorization procedure will put some object into session (as a flag for authorized users). And name for this object should be described for Forum as a parameter authorized. Servlet checks session and if there are no such attribute than request will be forwarded or redirected to the page, described as a parameter login.

If login value starts with http than request will be redirected to that site. Otherwise servlet assumes a local resource and forwards request.

Notes

1. Configuration file can be saved anywhere on your server. In case of usage
wwwboardServlet?file_name we assume that this file is saved under the root directory of your servletrunner. But you can always use the full name for setting file's location. E.g. you can type some like:
http://your_host/servlet/wwwboard?c:\myfiles\myconfig.txt

or
http://your_host/servlet/wwwboard?/home/users/me/myconfig.txt

Or you may use full path relatively to your root. E.g.:
http://your_host/servlet/wwwboard?/config.txt

2. Evaluation version displays the 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),
Moment CHAR(14),
Author CHAR(80) is null,
Email CHAR(80) is null,
Url CHAR(80) is null,
ip char(15) is null,
NrOfLines CHAR(6) is null,
Subject CHAR(80) is null,
Msg LONG VARCHAR is null);

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.

Interface translation

You can describe your own text file with labels (static HTML/WML elements). This file should be defined through a parameter labels in your config. It is a plain text file, each line describes one label in the form of:

label=new value

E.g.:

Author=Sender
Submit=Post message

etc.

Possible labels are:
Actions, Author, Back, e-mail, From, lines, Main, Message, Next, New message, Pages, Post, Post message, Re, Reply, See thread, Subject, Submit, Thread, Url
 

    For downloading:   wwwboardPackage.jar
    Sample of configuration file:  board

 © Coldbeans     Comments?

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

Also in JSOS: