This is a Java servlet implements messages forum (or guestbook). Forum supports WAP/WML also so it can be used for your mobile users too. You may use this servlet for example as a guestbook, as a discussion thread, as a place for news/announces in your Intranet etc. Forum 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 forumPackage.jar into your WEB-INF/lib directory. b) define servlets in your web.xml file. There are two servlets:
ForumServlet for forum itself and AdminForumServlet for administration:
<servlet> <servlet-name>Forum</servlet-name> <servlet-class>com.jsos.forum.ForumServlet</servlet-class> </servlet> <servlet>
define a mapping:
<servlet-mapping> <servlet-name>Forum</servlet-name> <url-pattern>/servlet/Forum</url-pattern> </servlet-mapping> <servlet-mapping>
For each your forum you must provide a configuration file describes how to save messages as well as various interface settings. You can use ForumServlet (or AdminForumServlet) in two forms. a) pass configuration file as a parameter. E.g.:
http://your_host/servlet/Forum?config_file b) define your configuration file as an initial parameter for servlet
(parameter name is config):
<servlet> <servlet-name>Forum</servlet-name> <servlet-class>com.jsos.forum.ForumServlet</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/Forum 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
#
# JNDI name (instead of the above mentioned pair)
# Optional parameter: user name for JDBC connection.
# name of the table
# Interface # forum title (default value is Coldbeans forum)
# style. Describes an URI for your CSS style file. By default is empty. E.g.:
# background (default value is #FFFFFF)
# you can set also different backgrounds for odd and even messages
# odd messages
# even messages
# background for titles (default value is #D8CEC0)
# you can set also different backgrounds for odd and even titles
# odd titles
# even titles
# foreground color (default value is #000000)
# you can set also different foreground color for odd and even messages
# odd messages
# even messages
#font size (by default is current browser's font)
#font face (by default is current browser's font)
# sort data: 1 - last to first, 0 - first to last (default value is
1)
# Date format. By default board will use full date.
# offset. By default forum will use server's time (offset=0). You can
# refresh time in the seconds (default 300)
# read forum: 1 - yes, 0 - no (default value is 1)
# ask/do not ask user's email. 1 - yes, 0 - no (default value is 1)
# ask/do not ask user's url. 1 - yes, 0 - no (default value is 1)
# enable/disable posting for messages. By default this parameter is empty
# administrator's password. See Administrative mode below.
# authorization flag (See Authorization section below)
# login page
# page size in messages (default value is 10)
# header. You can set here some file contains any html-code. This code
will be
# footer. You can set here some file contains any html-code. This code
will be
# Localization support. # You can set character encoding for input parameters
# Charset. You may describe exclusively charset for output pages.
Administrative mode You can manage by your message store if you run AdminForumServlet. Here you can for example delete your messages. You can set administrator's password as a parameter in your configuration file. Parameter's name is admin. Default value for this password is welcome. 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 (
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 change types from CHAR to VARCHAR also. 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. Interface translation You can describe your own text file with text labels (static HTML/WML elements). This file should be defined through a parameter labels in your configuration file. It is a plain text file, each line describes one label in the form of: label=new value E.g.: Author=Sender
Possible labels are:
CSS settings You can add your own CSS file (see style parameter in config file) and set your own styles for interface's elements. For example: /* textarea for input */ textarea { width:225px; height:100px; } /* title */ h2 { font-size:50%; } /* input fields */ input[type=text] { width:170px; } /* Submit button */ input[type=submit] { width:90px; } /* Reset (clear) button */ input[type=reset] { width:90px; } Notes 1. You can save configuration file anywhere on your server. Just
use the proper path for setting servlet's parameter. Short path (just a name
of the file) means that your configuration file is saved under servletrunner's
root (docBase) directory. But you can always use an absolute path to your
config file as a parameter. E.g. some like this:
2. Also the base directory for messages store can be created anywhere on your server (just check out access rights). 3. Evaluation version displays the first two pages only. For downloading: forumPackage.jar Sample of config file: fconf © Coldbeans Software Comments? See also JSOS - the largest collection of servlets and filters.
|
Also in JSOS:
|