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):
 


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

or for creating a separate window:
 


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

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:
 


    <servlet>
    <servlet-name>Community</servlet-name>
    <servlet-class>com.jsos.community.Community</servlet-class>
    </servlet>

c) define a mapping:
 


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

the usage is:
 


    http://your_host/servlet/Community?unique_key

    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.:
 


Community?development
Community?marketing
etc.

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:
 


<servlet>
   <servlet-name>Community</servlet-name>
   <servlet-class>com.jsos.community.Community</servlet-class>
   <init-param>
     <param-name>config</param-name>
     <param-value>path_to_your_configuration_file</param-value>
   </init-param>
</servlet>

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:

# 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
dir=your_directory

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

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

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

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

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

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

# title. Default value is 'Coldbeans community'
title=Acme

# 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.
header=your_file

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

# Admin's password. Default value is welcome
password=your_secret_word

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

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

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

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

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

# 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.
format=1

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

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

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

# Size for input field
# Default value is 50
input=30

# 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.
login=full_path_to_your_html_file

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

Administrative mode

You may run this servlet without keyword:
 


    http://your_host/servlet/Community

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:

Username:

 

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

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();
 


<html>
 ...
 <form name=myform" method="post" action="http://your_host/servlet/Community?acme">
  <input type="hidden" name="user">
 </form>
 ...
 <script language="JavaScript">
  document.myform.user.value='Guest';
  document.myform.submit();
 </script>
</html>

Notes:

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: