Import servlet

The actual data can be sent to the equanda generated application using a servlet. Alternatively a web page can be provided (and by default it is), where you can cut and past the import file.

The servlet can be called with code like the following :

URLConnection cnx=url.openConnection();

// Set connection parameters
cnx.setRequestProperty("Content-Type", "text/plain");

// write the request
Writer out=new BufferedWriter(new OutputStreamWriter(cnx.getOutputStream()));
// write the data

// now read the response
BufferedInputStream in=new BufferedInputStream(cnx.getInputStream());
// handle the reply

If the data file starts with "data=� then this is removed from the data (this is done to allow the data to come from a form).

The servlet send a short replies with "OK" if the file was processed properly.
If there was a problem during the import, the reply is "FAILED " followed by a human readable reason of failure.

If your servlet is secured (it should be), then it is best to use the org.equanda.client.ImportClient class.
This will handle the login both in case of BASIC and FORM based authentication.

The actual servlet can be generated with a ant task like the following :

<config name="extra">
<attribute name="ejb-package" value="test"/>

Note that "import� is a reserved word in Java and thus cannot be used as package name.

To use the servlet, a definition like the example which follows has to be added to your web.xml file in your web archive.


Obviously, this servlet also has to be mapped to a URL, but that�s all there is to it.

Charset issues

On the servlet connection, it is possible to indicate the character encoding which is used in the communication.
This can be modified as needed on the client side to match the charset for the text file.

  • 1. Import servlet
  • 1.1. Charset issues