NanoXFServer

  • What is it?
    NanoXFServer is a really small web server based in Java that can handle put and xml-urlencoded-post XForms submission methods.

    It´s based in the smallest, fully functional WebServer available in
    Java: NanoHTTPD http://elonen.iki.fi/code/nanohttpd/

  • Why a Web Server for XForms?
    If you are developing XForms using a javascript based implementation
    (probably XSLTForms), you must be facing two problems if you want to
    run your XForms locally: 

    1. For security reasons, javascript is disabled (fully or partially,
      depending on your browser) when you open a local file in your browser,
      so your XForms won’t work.
    2. There is no way of saving the XML Instance data to a local file (for
      security reasons also), so you need javscript tricks or a full web
      server if you want to see the XForm data

    The purpose of NanoXFServer is to allow XForms to run locally for
    testing (or maybe for full local applications) without an Web Server
    (like Apache or eXist-db)

  • How it works?
    The simplest way of using NanoXFServer is to copy nanoxfserver.jar to
    the folder where your XForms resides, and then run it with the following
    command: 

    java -jar nanoxfserver.jar

    Then point your browser to http://localhost and you´ll get a listing of
    the files on your directory. Choose your XForms and it’s running.

    Take in account that you’ll need two prerequisites:

    1. You’ll need Java JRE installed on yout computer
    2. If you are using a client based XForms Implementation (like XSLTForms)
      you´ll need the appropiated files (xsltforms folder) and processing
      instructions in your XForms, in order to get it running

    For saving your instances locally, use the PUT submission method,
    and specify a relative file name in the action or resource attribute
    of the submission element, like this:

    <xf:submission id=”doput” resource=”data/putdata.xml” method=”put”  />

    XML Instance will be stored in a file named putdata.xml under the data folder
    (the folder must exists)..

    If you are using XSLTForms, you can also use the xml-urlencoded-post method,
    this way:

    <xf:submission id=”dopost” resource=”postdata.xml”
    method=”xml-urlencoded-post”>

    Using  xml-urlencoded-post, the browser will show the
    resulting instance (useful for quick testing)

  • What can it do?
    NanoXFServer adds the following features to NanoHTTPD: 

    • Support for PUT submission method.
    • Support for  xml-urlencoded-post submission method
      (supported in XSLTForms).
    • XML Instances are saved with UTF-8 file encoding
    • Inhibits use of .. on instance saving.
    • Serves the following file extensions as etxt/xml: .xml .xsl .xslt .xsd
      .xforms
    • Serves .xhtml files as application/xhtml+xml (not supported for all
      browsers)

    Here is a complete list of features form the NanoHTTPD web page:

    • Only one Java file
    • Java 1.1 compatible
    • Released as open source, Modified BSD licence
    • No fixed config files, logging, authorization etc. (Implement by
      yourself if you need them.)
    • Supports parameter parsing of GET and POST methods
    • Parameter names must be unique. (Adding support to multiple instance
      of a parameter is not difficult, but would make the interface a bit
      more cumbersome to use.)
    • Supports both dynamic content and file serving
    • Supports file upload (since version 1.2, 2010)
    • Never caches anything
    • Doesn’t limit bandwidth, request time or simultaneous connections
    • Default code serves files and shows all HTTP parameters and headers
    • File server supports directory listing, index.html and index.htm
    • File server supports partial content (streaming)
    • File server supports ETags
    • File server does the 301 redirection trick for directories without /
    • File server supports simple skipping for files (continue download)
    • File server serves also very long files without memory overhead
    • Contains a built-in list of most common mime types
    • All header names are converted lowercase so they don’t vary between
      browsers/clients
  • Download
    You can download executable jar + source code packed in a ZIP file
    Download
    NanoXFServer is Open Source software licensed under BSD licensePortions come from NanoHTTPD project licensed under BSD also.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>