Notepad servlet 1.9

It is a Java servlet implements a collection of notes. You can save a list of text notes on your server and manage them by this servlet. Component supports WAP/WML, so your mobile users will have access to the same collection of notes.

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

b) define NotepadServlet in your web.xml file:
 


    <servlet>
     <servlet-name>NotepadServlet</servlet-name>
     <servlet-class>com.jsos.notepad.NotepadServlet</servlet-class>
    </servlet>

c) define a mapping:
 


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

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

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


http://your_host/servlet/NotepadServlet?config_file

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


    <servlet>
     <servlet-name>NotepadServlet</servlet-name>
     <servlet-class>com.jsos.notepad.NotepadServlet</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/NotepadServlet

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:

# 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.
#
# File based persistence
#
# base directory - no default settings. This parameter must be defined
# in case of file based persistence.
base=path_to_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 first table
table1=your_db_table
# name of the second table
table2=your_db_table
# See below DDL description for data tables

# Interface

# how to sort messages. 1 - by date, 2 - by titles. (default value is 1)
sort=1

# background color (default value is #ADD8E6)
bgcolor=#ADD8E6

# foreground color (default value is #000000)
fgcolor=#000000

# table (list of notes) colors:

# table's background (Default value is #CFAFB7)
tablebgcolor=#CFAFB7

# table's foreground. (Default value is #000000)
tablefgcolor=#000000

# you can set also different colors for odd and even rows in the main table.

# odd rows. Default value is #FFFFE0
oddrowcolor=#FFFFE0

# even rows. Default value is #ADD8E6
evenrowcolor=#ADD8E6

# allows modification (1 or 0. Default value is 1 - you can add, edit, delete notes)
modify=1

# 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 Notepad
title=My notepad

# head. You can set here some file contains any html-code. This code will be
# outputted at the beginning of each page. So you can set for example some banners.
# By default this value is empty
head=path_to_your_file
 

More about database persistence

All data will be saved in two tables. Names for tables are included in your configuration file (table2=first_table, table2=second_table). So if you support several collections each of them must have own pair of tables (probably in the same database). Tables 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 that tables:

CREATE TABLE first_table_name (
Id CHAR(30) PRIMARY KEY,
Msg LONG VARCHAR);

CREATE TABLE second_table_name (
Id CHAR(30) PRIMARY KEY,
Id1 CHAR(30),
Moment CHAR(14),
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. 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.

Note: 1. Notepad's configuration file can be saved anywhere on your server. E.g. if you are using NotepadServlet?config line we assume this file is saved under the root directory of servletrunner. But you can of course always use full name for setting config file location: NotepadServlet?/home/users/my_file (or NotepadServlet?c:\users\my_file)

2. Free version supports up to 3 notes per folder
 

    For downloading:   notepadPackage.jar
    Sample of configuration file: noteconf

 © Coldbeans      Comments?

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