Rimfaxe Web Server Documentation

>> Documentation >> Configuration >> Deploying a web application


Rimfaxe Web Server Configuration.

This document describes how to configure Rimfaxe Web Server.
Note that RWS is short for Rimfaxe Web Server.

This document provides info on deploying a web-application, including defining taglibs, servlets, and filter chains.

The web-application is deployed through WEB-INF/web.xml in the root directory of the web application.


Setting up web application in RWS.
To deploy a web application, the location of the web-app must be defined in the RWS configuration. In the RWS install dir open config/rimfaxe-webserver.xml and edit the virtual host where the web-app is to be deployed. The xml looks like this :

   <webcontext name="ROOT">
     <root> /foo/bar/pub </root>
     <urlpath> / </urlpath>
   </webcontext>

   <webcontext name="EXAMPLES">
     <root> /foo/bar/demo </root>
     <urlpath> /examples/ </urlpath>
   </webcontext>
          
This defines the webcontext for the web application. The name attribute is your name for the webcontext. The root tag is the directory where the web application is installed. This must be a directory and not a war file, since RWS doesn't support war files yet. The urlpath tag defines the prefix to access the web application. If there is a JSP file in the ROOT context /foo/bar/pub/some.jsp, it is accessed in a browser with the path /some.jsp. And if there is a JSP file in the EXAMPLES context /foo/bar/demo/another.jsp, it is accessed in a browser with the path /examples/another.jsp.



Servlets.
To define a servlet, edit the web application description file in WEB-INF/web.xml.
The definition looks like this :

   <servlet>
      <servlet-name>ExampleServlet</servlet-name>
      <servlet-class>foo.bar.ExampleServlet</servlet-class>
      <init-param>
        <param-name>debug</param-name>
        <param-value>0</param-value>
      </init-param>
      <load-on-startup> 1 </load-on-startup>
   </servlet>
          
servlet-name is a name that describes the servlet. The name is used in the mapping of the servlet. servlet-class is the full name of the class implementing the servlet.

init-param is an initialization parameter, which is passed to the init method of the servlet when it is loaded.

load-on-startup means that the servlet should be loaded on startup instead of first use. The value determines which servlet is to be loaded first. A servlet with load-on-startup = 3 is loaded before a servlet with load-on-startup = 4. The value -1 means load on first use.

The servlet source code goes into WEB-INF/rws/src.

The servlet can be reached in the default configuration of RWS by the url /servlet/foo.bar.ExampleServlet. But generally the servlet needs to be mapped to an url. The xml looks like this:
   <servlet-mapping>
        <servlet-name>ExampleServlet</servlet-name>
        <url-pattern>/s/example</url-pattern>
   </servlet-mapping>
          
servlet-name is the name of the servlet, url-pattern is the url pattern that should be handled by the servlet. It is allowed to use a single wildcard (*) in a url pattern. The following patterns are legal patterns in RWS :

/some/path/*
*.extension
/some/path/*.extension
/some/path/*/continues

Patterns with two wildcards is accepted, but not properly recognized due to a limitation in RWS :

/some/path/*/more/*.extension



Taglibs.
Taglibs is deployed with a tld file and an entry in web.xml that looks like this :

   <taglib>
     <taglib-uri>/examples</taglib-uri> 
     <taglib-location>/WEB-INF/examples-library.tld</taglib-location> 
   </taglib>
          
taglib-uri is an unique uri used to identify the tag library. taglib-location points to the file where the tag library is defined (tld format).



Filter chains.
RWS supports filters. A filter is an object that can transform a request or modify a response or both. They are preprocessors of the request before it reaches a servlet, and/or postprocessors of the response leaving a servlet.

The definition of a filter looks like this :

   <filter>
        <filter-name>TimerFilter</filter-name>
        <filter-class>com.rimfaxe.webserver.servletapi.filter.TimerFilter</filter-class>
   </filter>
          
filter-name is a descriptive name of the filter. It is used to reference the filter from its mapping. filter-class is the class that implements the filter. The class should be deployed as a source file in WEB-INF/rws/src.
TimerFilter is included in RWS, and measures the time it takes to process a request and prints it on std out. See webroot/examples/WEB-INF/web.xml in the examples context for an example on how to use it.

A filter must be mapped to an url pattern. Here is an example that maps TimerFilter on JSP pages :
   <filter-mapping>
        <filter-name>TimerFilter</filter-name>
	<url-pattern>*.jsp</url-pattern>
   </filter-mapping>
          



Static content.
RWS offers the feature of configuring static content in web.xml. The static content is then served directly through the SEDA engine with effective caching and nonblocking IO.

Define static content like this :

   <static-mapping>
        <file-type>HTML</file-type>
        <url-pattern>*.html</url-pattern>
        <max-age> -1 </max-age>
   </static-mapping>

   <static-mapping>
        <file-type>JPEG</file-type>
        <url-pattern>*.jpg</url-pattern>
        <max-age> 600 </max-age>
   </static-mapping>

   <static-mapping>
        <file-type>pictures</file-type>
        <url-pattern>/pictures/*</url-pattern>
        <max-age> 600 </max-age>
   </static-mapping>
          
file-type is simply a descriptive name for the filetype. url-pattern maps the files to be considered of this type. Note that it is possible to map an entire subdirectory as static content.
max-age is sent to the browser, and tells the browser how long it is allowed to hold the file in the browser cache, before it must be requested again. The value of max-age is in seconds.