UIEvolutin Inc.
UJML Application Development User Guide
Deploying Server-side Components

This topic describes how to configure and deploy UJML applications on a Java Servlet server.

There are several steps to configuring a server. These steps are completed automatically in the Tomcat instance that is included with this SDK; but if you wish to deploy server-side pieces on any other Java application server, you will need to verify that each of these steps is done correctly.

JAR files

There are two JAR files that need to be included on the classpath of the application server:

  • compiler.jar
  • uietools.jar

These are included in the lib directory of each context in the Tomcat installation, and need to be deployed in a comparable location in other application servers.

Servlets

There are two servlets that should be defined in each context of the application server. There may also be additional servlets or additional servlet instances with different initialization parameters.

Compiler servlet

The Compiler servlet is used to take requests for dynamically-generated source code from the same application server and context and compile the output into byte code that is returned to the client. 

The Compiler servlet uses the class com.uievolution.ujml.servlet.FilterServlet. The relevant pieces of the web.xml file for Tomcat are:

<servlet>
  <servlet-name>Compiler</servlet-name>
  <servlet-class>com.uievolution.ujml.servlet.FilterServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>Compiler</servlet-name>
  <url-pattern>/compile/*</url-pattern>
</servlet-mapping>

 

The same servlet and its mapping should be defined for any server-based deployment.

UJBC servlet

The UJBC servlet is used to take application requests that end in .ujbc and, when no .ujbc file exists, find the comparable .ujml file, compile it into byte code, and deliver it to the client. 

The UJBC servlet uses the class com.uievolution.ujml.servlet.UjbcServlet. The relevant pieces of the web.xml file for Tomcat are:

<servlet>
  <servlet-name>Ujbc</servlet-name>
  <servlet-class>com.uievolution.ujml.servlet.UjbcServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>Ujbc</servlet-name>
  <url-pattern>*.ujbc</url-pattern>
</servlet-mapping>

 

The same servlet and its mapping should be defined for any server-based deployment.

Forward servlet

The Forward servlet is used to take requests for dynamically-generated source code from a different Web server and compile the output into byte code that is returned to the client. 

The Forward servlet uses the class com.uievolution.ujml.servlet.FilterServlet. The relevant pieces of the web.xml file for Tomcat are:

<servlet>
  <servlet-name>ForwardServlet</servlet-name>
  <servlet-class>com.uievolution.ujml.servlet.FilterServlet</servlet-class>
  <init-param>
    <param-name>base-url</param-name>
    <param-value>http://yourserver.yourcompany.com:80/yourpath/</param-value>
  </init-param>
</servlet>
<servlet-mapping>
  <servlet-name>ForwardServlet</servlet-name>
  <url-pattern>/redirect/*</url-pattern>
</servlet-mapping>

 

The specific values of base-url and mapping will vary depending on your configuration. If you want to allow a variety of base-urls to be used to generate UJML source code, then each one must have a different servlet instance. The server at that location must set the MIME type of the UJML source code as text/xml.

Compiler parameters

There are a number of parameters that can be set for the compiler that may be useful, or even required, depending on your deployment needs. These parameters can be added to any servlet that invokes the compiler, including the Compile servlet, the Ujbc servlet, and the Forward servlet.

Debugging

If you wish to use debugger features to develop applications, it is necessary to turn on these features when generating source code. These settings are typically not included on deployed applications, but can be useful during the application development process. 

To allow the debugger to request files with viewable source code, the servlet should include the setting:

<init-param>
  <param-name>compiler-option-debug</param-name>
  <param-value>true</param-value>
</init-param>

 

To allow the debugger to view the outputs of _trace() statements, the servlet should include the setting:

<init-param>
  <param-name>compiler-option-trace</param-name>
  <param-value>true</param-value>
</init-param>

 

To control conditional compilation using statements within the UJML source code such as <?ujml-ifdef APPSERVER?> the parameter values are defined using:

<init-param>
  <param-name>compiler-define-APPSERVER</param-name>
  <param-value>true</param-value>
</init-param>

 

By default, when the compiler encounters an error in UJML code, it generates an error page that is visible within the player. This behavior helps in the development process in identifying errors during the UJML generation process. 

During commercial deployment, it may be useful to turn this behavior off. In lieu of generating an error page visible by the player, the compiler can throw a server error, writing information about the error in the server log, and returning a 500 error code to the client. The user will not see the requested file load, but will also not see the error description page. The syntax for controlling this features is:

<init-param>
  <param-name>disable-error-page</param-name>
  <param-value>true</param-value>
</init-param>
License

By default the compiler is restricted to requests generated by the UIEvolution SDK. If you want to use the compiler for other purposes (such as testing your application on commercial networks and devices), you will need additional license information from UIEvolution. This information should be added to each relevant servlet in the form:

<init-param>
  <param-name>compiler-license-key</param-name>
  <param-value>XXX</param-value>
</init-param>
<init-param>
  <param-name>compiler-license-component</param-name>
  <param-value>compiler</param-value>
</init-param>
<init-param>
  <param-name>compiler-license-type</param-name>
  <param-value>internal testing</param-value>
</init-param>
<init-param>
  <param-name>compiler-license-owner</param-name>
  <param-value>Your Company</param-value>
</init-param>
<init-param>
  <param-name>compiler-license-instance-limit</param-name>
  <param-value>0</param-value>
</init-param>
<init-param>
  <param-name>compiler-license-frequency-limit</param-name>
  <param-value>0</param-value>
</init-param>
<init-param>
  <param-name>compiler-license-allow-list</param-name>
  <param-value>true</param-value>
</init-param>
<init-param>
  <param-name>license-key</param-name>
  <param-value>XXX</param-value>
</init-param>
<init-param>
  <param-name>license-component</param-name>
  <param-value>servlet</param-value>
</init-param>
<init-param>
  <param-name>license-type</param-name>
  <param-value>internal testing</param-value>
</init-param>
UJML Source

Because the servlets that generate compiled byte code will only compile source code of MIME type text/xml, it is necessary to explicitly set the MIME type of UJML source code. For static files this is done using:

<mime-mapping>
 <extension>ujml</extension>
 <mime-type>text/xml</mime-type>
</mime-mapping>

 

For other file types (such as JSP, CGI, or PHP) there are other mechanisms for setting the MIME type. If the compiler encounters source code on which the MIME type has not been set correctly, it will forward the source code without compiling it, and the result will be incomprehensible to the client.

Copyright (c) 2000-2005 by UIEvolution, Inc. All rights reserved.
What do you think about this topic? Send feedback!