SaveData ver. 1.5

    Java servlet allows you to save some field value from your HTML form in the file. For example, with this component you may collect subscription addresses etc. User's input can be e-mailed also to the given address.

You must set this servlet as an action parameter for your form. Servlet collects posted data and proceed them according to own configuration file. Configuration file describes how save your data as well as your mail settings.

How to use it:

a) copy saveDataPackage.jar into WEB-INF/lib directory

b) describe servlet in your web.xml file:

    <servlet>
     <servlet-name>SaveData</servlet-name>
     <servlet-class>com.jsos.savedata.SaveDataServlet</servlet-class>
    </servlet>

You can pass configuration file as a parameter to this servlet and use it in this form:

    http://your_host/servlet/SaveData?config_file

    E.g. some like this:

please type your e-mail address: 

or in html-tags:

<html>
<br>please type your e-mail address:
<form action="http://your_host/servlet/SaveDataServlet?c:\files\my_config.txt" method="post">
<input type="Text" name="what">    <input type="submit" value="Subscribe">
</form>
</html>

or you may describe configuration file as an initial parameter (parameter name is config):

    <servlet>
     <servlet-name>SaveData</servlet-name>
     <servlet-class>com.jsos.savedata.SaveDataServlet</servlet-class>
     <init-param>
      <param-name>config</param-name>
      <param-value>path_to_your_config_file</param-value>
     </init-param>
    </servlet>

and use servlet in this form:

    http://your_host/servlet/SaveData

Configuration file is a text file describes servlet's settings. You can save this file anywhere on your server. Configuration file has got free format, but description of any parameter must starts with an appropriate reserved word on the new line. Each line has the following form:

parameter:value

    Current version supports the following list of parameters:

    Data: describes full path for data file. By default it is savedata.txt in the root directory of your servletrunner.
    Field: describes the name of the field from html-form. By default it is what
    Reply: you can set here url for the page that will displayed after data saving. See Notes below.
    Encoding: localization support. You can set character encoding for input parameters  here. Default value is ISO-8859-1. E.g.:

Encoding:Cp1251

    You can also e-mail user's input to some address. Here is a list of parameters you can use for mail settings:

    Mailhost: describes your smtp host. This parameter is mandatory
    Port: describes smtp port. By default it is 25.
    Domain: describes your domain. This parameter is mandatory.
    From: describes source address. This parameter is mandatory.
    To: describes destination address. This parameter is mandatory.
    Cc: describes cc settings for your letter
    Subject: set letter's subject
    Body: set letter's body
    Attach: you can set here a list of files you need to attach to composed letter.

    When you describe contents of any mail-related fields, you can use also constructions like $data as a reference for user's input. E.g. for the above mentioned example you can set some like this:

To:me@mycompany.com
Subject:subscribe me
Body:$data

here $data will be replaced with the actual value of user's input.
When you set attachments you can set a list of commas separated files.

Notes:

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

2. If reply value starts with http than request will be redirected to that site. Otherwise servlet assumes a local resource and forwards request.

for downloading:

servlet: saveDataPackage.jar  

sample of configuration file:  saveconf

 © Coldbeans Software     Comments?

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