Calendar servlet 3.0

It is a Java servlet implements calendar. You can use it as a standard calendar system, for booking some resources etc. Calendar supports WAP/WML so you can use it even from your mobile phone.

Calendar's users may by notified by e-mail about schedule changes.

Calendar 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 calendarPackage.jar into your WEB-INF/lib directory.

b) define servlet in your web.xml file.
 


    <servlet>
     <servlet-name>CalendarServlet</servlet-name>
     <servlet-class>com.jsos.calendar.CalendarServlet</servlet-class>
    </servlet>

c) define a mapping for Calendar servlet in your web.xml file.
 


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

For each your calendar you must provide a configuration file describes how to save messages as well as various interface settings. You can use CalendarServlet in two forms.

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

http://your_host/servlet/CalendarServlet?config_file

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


    <servlet>
     <servlet-name>Calendar</servlet-name>
     <servlet-class>com.jsos.calendar.CalendarServlet</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/Calendar

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:

#
# Calendar settings
#
# data persistence. You can use file based persistence or save
# your data in the any database supports JDBC.
# So you must either set the base directory for file based persistence
# or describe a JDBC connection to your database.
# Options for database persistence are: (JDBC driver, database URL) pair or JNDI datasource
#
# File based persistence
#
# base directory - no default settings. This parameter must be set in
# case of file based persistence.
base=path_to_your_directory
#
# JDBC settings. You must set this in case db-based persistence
#
# 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

# background color for the left frame (default value is #FFFFFF - white)
bgcolor1=#FFFFCC

# foreground color for the left frame. (default value is #000000 - black)
fgcolor1=#000000

# font size for the left frame (by default is default browser's font size)
size1=2

# font face for the left frame (by default is current browser's font size)
face1=Arial,Verdana

# background color for the main (right) frame (default value is #FFFFFF - white)
bgcolor2=#FFFFC0

# foreground color for the main (right) frame (default value is #000000 - black)
fgcolor2=#000000

# color for events titles (default value is #0000FF - blue)
fgcolor3=#0000FF

# font size for the right frame (by default is current browser's font size)
size2=6

# font face for the right frame (by default is current browser's font size)
face2=Arial,Verdana

# escape HTML - disable/enable HTML tags in posts
# 1 - disabled, 0 - enabled. Default value is 1
escapeHTML=1

# frames setting - how to split the screen. (Default value is 25%,75%)
# You can use non-frames version too. In this case set frames=0
frames=30%,70%

# Initial view (in case of non-frames version).
# 1 - day, 2 - week, 3 - month. Default value is 1
view=2

# How to show week/month view. You may set a target
# frame here. Default values are _top for frames based version
# and _self for non-frames version
target=name_of_your_frame

# frame border (default is 0)
border=1

# enable/disable frames resize. Default value is 1 (enabled)
resize=0

# title for the main frame (default value is empty - no title)
title=My calendar

# calendar style: 1 - first day of week is Monday
# 2 - first day of week is Sunday
# default value is 1
style=1

# time settings. 1 - one time stamp per event,
# 2 - two stamps (from - to)
# default value is 1
time=1

# enable/disable add 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
add=list_of_roles

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

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

# max size for subjects. Default value is 60.
subject=75

# allows more that one record to be assigned for the same time.
# 1 - yes, 0 - no. (default value is 0). E.g. you can use this servlet
# for booking system and allow only one record to be assigned on the
# particular time.
share=1

# proxy servers support. You can define an URL that will be
# used in all likns instead of real servlet's address.
# By default real servlet's URL will be used
baseurl=your_url

# 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 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 of the each page. So you can set for example some banners.
# By default this value is empty
footer=path_to_your_file

# 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

# locale (country) support. Default value is US. Possible values
# are CHINA,FRANCE,GERMANY,ITALY,JAPAN,KOREA,TAIWAN
locale=GERMANY

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

# login page
login=your_page

#
# mail settings. Use this in case you need e-mail notification
#

# smtp host
host=relay.yoursite.com

# smtp port. Default value is 25
port=25

# mail domain
domain=yoursite.com

# address 'From'. Notification will be send from this address
from=helpdesk@yoursite.com

# list of users. Text file (comma separated) with the list
# of e-mail addresses.
list=full_path_to_your_emais_file

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,
Moment CHAR(8),
tStart CHAR(5),
tEnd CHAR(5),
Subject CHAR(80),
Msg LONG VARCHAR);

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.

Authorization

You may incorporate this Calendar into your portal where your users will be authorized. In order to prevent access to this calendar 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 Calendar 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. Calendar's configuration file can be saved anywhere on your server. E.g. if you are using
CalendarServlet?config.txt  we assume this file (config.txt) is saved under the root directory of your servletrunner. But you can of course always use full path for setting config's file location. E.g. some like this: CalendarServlet?/home/users/my_file (or CalendarServlet?c:\users\my_file)

2. Base directory is any existing directory on your server. Just check out read/write rights

3. For database persistence make sure you add your JDBC driver to CLASSPATH.

4. Evaluation version supports up to 5 events per day.

    For downloading:   calendarPackage.jar 
    Sample of configuration file: calconf

 © Coldbeans Software     Comments?

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