Summary
 


Introduction
Embedded database use
Embedded Web server
OpenMIS servlet & services

 
  Abstract
 


This document is a tutorial about the embedded web server use.




Author: P.delrieu        Last update: 02/07/2006

 
 
 
 
Embedded Web Server

Starter class

OpenMobileIS provides a "Starter" to run its embedded web server.
The "Starter" class is:
org.openmobileis.embedded.webserver.StartWebServer.

Its main method starts the web server, looking for its configuration file ('properties/webserver.properties').

Depending on the jvm used, the 'properties/webserver.properties' will or will not be found in the classpath. If the jvm does not look for files into its classpath (as it's the case with IBM's j9), the StartWebServer main method accepts a parameter, which is the absolute path to the directory containing 'properties/webserver.properties'.

Configuration files

- Main configuration file
When starting, the embedded webserver parses its main configuration file (properties/webserver.properties). It can contain three properties :

port=<port-number>  (optional)
This is of course the port number the web server will be listening on. If not declared, the webserver will listen on port 8080 by default.

. installPath=<install-path>  (required)
This is the execution directory of the web server. This is important, as it will be the path added in the getRealPath() method of the servlets loaded by the web server.

servletFile=<servlet-configuration-file>
  (required)
Just as Tomcat, the embedded web server parses a file, where servlets are declared. This configuration file is detailed in the comming part.

- Servlet configuration file
This servlet configuration file is more simple than Tomcat one's. It can only take two types of arguments
servlet.<servlet-name>.code=<servlet-class>
servlet.<servlet-name>.initArgs=<name=value>,<name=value>

These arguments have to be repeated for each servlet declared.
In order to run Open Mobile IS, we need to declare the openmis servlet, with the right init arguments. We also need to declare the file servlet, provided by the project, as the default servlet. Indeed, Open Mobile IS' embedded web server does not have any default action to do when no servlet is found.
Declaring the file servlet as the default servlet allows to retrieve files (images for example) on the server. The servlet file then looks like :

servlet.services.code=org.openmobileis.services.servlet.OpenMISServlet servlet.services.initArgs=org.openmis.services.conffile=/WEB-
INF/conf/properties/openmis.properties servlet.defaultServlet.code=org.openmobileis.services.servlet.FileServlet servlet.defaultServlet.initArgs=htdocs=/htdocs

The argument taken by the file servlet (htdocs=<htdocs-dir>) defines the base directory where the servlet will look for files. If not defined, the base directory will be <installPath>, as defined in the server's main configuration file. Otherwise, it will be <installPath>/<htdocs-dir>.
The arguments taken by openmis servlet will be detailed in the next part.

To request a servlet the URI is constitued as follow:
/<servlet-name>.


For example these servlet properties :
servlet.myservlet.code=org.openmobileis.services.servlet.MyServlet
servlet.myservlet.initArgs= can be request with the URI: /myservlet





© Copyright OpenMobile IS 2005