CSV publishing ver. 1.2

        Java Servlet lets you quickly publishing so called commas separated values files. CSV files are text files where rows contain data separated by commas (separator is actually configurable). It is a standard and portable way to present source data in many systems. And this component simply lets you quickly display them on the web. How to use it:

1) copy csvPackage.jar into WEB-INF/lib directory

2) describe CSVPublishing servlet in your web.xml file:
 


    <servlet>
     <servlet-name>CSVPublishing</servlet-name>
     <servlet-class>com.jsos.csv.CSVPublishingServlet</servlet-class>
    </servlet>

3) describe a mapping for this servlet
 


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

You must provide a configuration file describes how to display your data as well as the various interface settings. You can use CSVPublishing in two forms:

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


http://your_host/servlet/CSVPublishing?config_file

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


    <servlet>
     <servlet-name>CSVPublishing</servlet-name>
     <servlet-class>com.jsos.csv.CSVPublishingServlet</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/CSVPublishing

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 - describes your data file. This parameter is mandatory
data=your_csv_file

# title. Describes a title for your page. Default value is empty (no title)
title=My data

# 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

# body. Describes a CSS style for the body. Default value is background-color:#FFFFFF
body=background-color:white

# firstRow. Describes a CSS style for the first row. Default value is background-color:#FFFFFF
firstRow=background-color:#FFFFFF

# oddRow. Describes a CSS style for odd rows. Default value is background-color:#FFFFFF
oddRow=background-color:#FFFFFF

# evenRow. Describes a CSS style for even rows. Default value is background-color:#FFFFF0
evenRow=background-color:#FFFFF0

# page. Describes a size for the pages (in rows). Default value is 50
page=50

# width. Describes a width for your data table. E.g.:
width=100%

# columns. Describes a commas separated list of displayed columns starting from 1.
# E.g.: 1,3,5 - outputs the first, third and fifth columns only
# By default is empty (all the columns will be printed)
columns=1,2,3

# separator. Describes a separator. Default value is ,.
# Possible values are ,; or t. Value t marks here a tab separator
separator=,

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

For JSP check out also CSV taglib in Coldtags suite

For downloading:

servlet: csvPackage.jar
sample of config file:  csvconf.txt
 

 © Coldbeans     Comments?

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

Also in JSOS: