Community servlet 1.9

It is a Java servlet implements a specialized chat. You can not only type your messages, but share documents (web pages, local files) also.

How does it work? You can place on your web page (HTML page or WML page) a hyperlink with the reference to this servlet. E.g. (for HTML):

  <a href="http://your_host/servlet/Community?acme" target="_blank">Acme Community</a>

or for creating a separate window:

  <a href="'http://your_host/servlet/Community?acme', 'Community', 'width=250, height=300, location=no, toolbar=no,menubar=no,scrollbars=yes,resize=yes');" >Acme Community</a>

What is this for? From one side it is just a quick chat for your pages. But with the ability of sharing files (pages) you can also use this servlet as an online help for visitors. Some like 'call center' - you can answer questions in the real time, demonstrate slides (files) with some additional explanations etc.

It is a pure HTML implementation, so this version is free from any firewall's restrictions.

Servlet supports WAP/WML, so mobile users can join your community.

How to use it:

a) copy communityPackage.jar into WEB-INF/lib directory

b) describe servlet in web.xml file. So for your web.xml you need to add some like this:


c) define a mapping:


the usage is:


    Runs the community with the given key. The own unique key will identify each community. You may choose any string for this key. So the same servlet can support more than one community. E.g.:


You must set common parameters for servlet in a configuration file. You need to setup a full path to this file as an initial parameter for servlet. Parameter's name is config:


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


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

# work directory. Points to any existing directory on your server
# This parameter is mandatory
# Note: servlet will use specified working directory for
# temp files only and all files from this directory will be deleted

# background color for messages screen.
# Default value is #FFFFFF (white)

# background color for command screen.
# Default value is #FFFFFF (white)

# foreground color for messages screen.
# Default value is #000000 (black)

# foreground color for command screen.
# Default value is #FFFFFF (black)

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

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

# title. Default value is 'Coldbeans community'

# header. You can set here a path your file with HTML content.
# This file will be outputted "as is" on the top of your pages.
# So you may define for example some banners etc.

# DHTML usage. By default is 1 (enable DHTML).
# You may set dhtml=0 for old browsers

# Admin's password. Default value is welcome

# Share web sites. 1 - enable, 0 - disable.
# Default value is 1.

# Share local files. 1 - enable, 0 - disable
# Default value is 1.

# How to announce new shared site.
# Default value is new site was suggested.

# How to announce new shared file.
# Default value is new document was suggested.

# settings for new windows with shared sites.
# Default value is:
# width=400,height=300,location=no,toolbar=no,menubar=no,scrollbars=yes,resize=yes

# Messages format. How to output messages.
# 1 - time user_name text_of_message
# 2 - time text_of_message
# 3 - user_name text_of_message
# 4 - text_of_message
# Default value is 1.

# Inactivity timeout for users (in seconds). User will be
# deleted if there are no new messages during that time.
# Default value is 600

# Messages timeout (in seconds).
# Default value is 10

# Session timeout (in seconds). Session will be closed if
# there are no new messages during that time.
# Default value is 1800 (30 minutes).

# Size for input field
# Default value is 50

# Login procedure.
# By default is empty (build-in dialog for login).
# You may set your own HTML file for login dialog
# See below how to write this file.

# Localization support. You can set encoding for input and output
# parameters. Default value is ISO-8859-1.

Administrative mode

You may run this servlet without keyword:


in this case you will be asked to enter administrative password (see parameter password) and servlet will provide forms for community monitoring. You will be able for example to search (see) all communities (chats, rooms) according to the given keyword pattern.

Login procedure

You can set your own HTML file for login dialog. You have to provide a form that submits user's name for Community servlet. Parameter name for the field is user.
E.g. in the simplest case such file contains only one form:



 <form method="post" action="http://your_host/servlet/Community?acme">
   Username: <input type="text" name="user"> <input type="submit" value="Submit">

You can even skip login dialog at all. You do not need to set parameter login for this. Just create in your HTML (JSP) file a form with the hidden field user, set an appropriate value for this field and submit this form through JavaScript: document.yourform.submit();

 <form name=myform" method="post" action="http://your_host/servlet/Community?acme">
  <input type="hidden" name="user">
 <script language="JavaScript">


1. Servlet's configuration file can be saved anywhere on your server.

2. Directory for temporary files can be created anywhere on your server.

    For downloading:   communityPackage.jar
    Sample of configuration file: commconf

 © Coldbeans Software     Comments?

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

Also in Coldtags: