Application environment

When the Genero Application Server starts an application process, it sets environment variables from various sources. Understanding how variables are defined by the various front-ends, is helpful to you when configuring applications.

The application process can be started as a DVM (fglrun), as an intermediate script, or whatever is specified in the application configuration file.

Environment inheritance

Environment variable settings are inherited by the DVM in the following order:

  1. The environment of the dispatcher that starts the proxy.
  2. The environment variables defined in the application configuration file (ENVIRONMENT_VARIABLE elements).
  3. Additionally, some specific environment variables can be defined by the front-end; whether this is Genero Desktop Client, Genero Browser Client, or Web service. See:

How to get the URL of the application

The FGL_VMPROXY_START_URL environment variable stores the real URL of an application. The real URL refers to the URL that the user clicked to start the application. Use the Genero fgl_getenv() function in your application to retrieve the value of the environment variable.
LET startUrl = fgl_getenv( "FGL_VMPROXY_START_URL" )

The variable name must be in uppercase.

Note: There are environment variables that are internal to the GAS, to include variables with the FGL_VMPROXY_ prefix. As the name suggests, these environment variables are set by the dispatcher starting the proxy. In general, you do not have access to these environment variables, however an exception was made for the FGL_VMPROXY_START_URL environment variable.

How GDC and GBC handle environment variables

With Genero Desktop Client and Genero Browser Client applications, variables can be set in the HTTP request that starts the application. All HTTP request headers are transformed into environment variables, by adding the FGL_WEBSERVER_HTTP_ prefix.

Note: Dash (or minus) (-) characters are replaced by underscore (_) characters. For example, the header "User-Agent" defines the FGL_WEBSERVER_HTTP_USER_AGENT environment variable.
Some variables transmitted by the Web Server are also added to the environment with FGL_WEBSERVER_ (without HTTP_) as prefix like the following that are supported for backward compatibility:
  • FGL_WEBSERVER_REMOTE_USER holds the REMOTE_USER value provided by the Web Server.
  • FGL_WEBSERVER_REMOTE_ADDR holds the REMOTE_ADDR value provided by the Web Server.

With Genero Browser Client applications, environment variables are also passed to the client bootstrap mechanism (bootstrap.html) that loads the user interface. This implementation, however, is reserved for internal use and is subject to change without notice. It must not be modified in any way. For more information, see the Genero Browser Client User Guide.

How GWS handles HTTP request headers

With Genero Web services applications, environment variables cannot be used to pass HTTP request headers. Low-level APIs are used to retrieve values from the HTTP request headers. The header name has the following form:

X-FourJs-Environment-Parameter-name

Where name is the header name. To get the header value, you use the com.HTTPRequest.getRequestHeader() method. For example:
LET param = req.getRequestHeader("X-FourJs-Environment-Parameter-MyHeaderName") 
The server name can be found in X-FourJs-Environment-Variable-SERVER_NAME.
Note: For more information on com.HTTPRequest methods, see the Web services classes chapter in the Genero Business Development Language User Guide.

How GWS with delegation handles HTTP request headers

When delegation is used in Genero Web services, the X-FourJs-Environment-Parameter-<parameter_name> is used by the delegate mechanism to pass any additional parameters defined in the as.xcf file of the application to the delegate service. For instance, in the following xcf delegation setting example using Security Assertion Markup Language (SAML) service :
<DELEGATE service="services/SAMLServiceProvider">
  <IDFORMAT>ABC</IDFORMAT>
  <AUTHCONTEXT>123</AUTHCONTEXT>
</DELEGATE>
The parameters IDFORMAT and AUTHCONTEXT are free, and can be passed to the delegate service as HTTP headers in the following form:

X-FourJs-Environment-Parameter-IDFORMAT : ABC

X-FourJs-Environment-Parameter-AUTHCONTEXT : 123