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
# title. Describes a title for your page. Default value is empty (no title)
# header. You can set here some file contains any html-code.
# footer. You can set here some file contains any html-code. This code
will be
# body. Describes a CSS style for the body. Default value is background-color:#FFFFFF
# firstRow. Describes a CSS style for the first row. Default value is background-color:#FFFFFF
# oddRow. Describes a CSS style for odd rows. Default value is background-color:#FFFFFF
# evenRow. Describes a CSS style for even rows. Default value is background-color:#FFFFF0
# page. Describes a size for the pages (in rows). Default value is 50
# width. Describes a width for your data table. E.g.:
# columns. Describes a commas separated list of displayed columns starting from 1.
# separator. Describes a separator. Default value is ,.
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
See also JSOS - the largest collection of servlets and filters.
|
Also in JSOS:
|