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:
- The environment of the dispatcher that starts the proxy.
- The environment variables defined in the application configuration file
(
ENVIRONMENT_VARIABLEelements). - Additionally, some specific environment variables can be defined by the front-end; whether this is Genero Desktop Client (GDC) and Genero Browser Client Genero (GBC), or Web service. See:
How to get the URL of the application
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.
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 to use environment variables in GDC and GBC
- Standard HTTP request header fields
- Web server Common Gateway Interface (CGI) environment variables
- HTTP request headers converted to FGL_WEBSERVER_HTTP_*
-
The
uaproxyconverts HTTP headers, such as theUser-Agent, to environment variables by adding theFGL_WEBSERVER_HTTP_prefix.Note: The GAS replaces the dash (or minus "If you need to use these variables in your application, use the Genero-") characters with underscore (_) characters. For example, it converts the header "User-Agent" to theFGL_WEBSERVER_HTTP_USER_AGENTenvironment variable.fgl_getenv()function to retrieve their value. For example to identify the client browser, you add a statement like this:LET user_agent = fgl_getenv( "FGL_WEBSERVER_HTTP_USER_AGENT" ) - Web server CGI environment converted to FGL_WEBSERVER_*
-
The
uaproxyconverts some CGI variables (see Table 1) transmitted by the Web server (Apache, IIS, etc.) by adding them to the GAS environment withFGL_WEBSERVER_as prefix. For more information on the standard specification, see rfc3875, or see your web server's documentation.Table 1. Web server environment variables Web server variables GAS converted variables Description REMOTE_ADDRFGL_WEBSERVER_REMOTE_ADDRReturns the network address of the client sending the request to the server. REMOTE_USERFGL_WEBSERVER_REMOTE_USERReturns the user name supplied by the client as part of user authentication. SERVER_NAMEFGL_WEBSERVER_SERVER_NAMEReturns the name of the server host to which the client request is directed. HTTPSFGL_WEBSERVER_HTTPSReturns " ON" if the request came in through a secure channel (for example, SSL); or it returns "OFF", if the request is for an insecure channel.Use the Generofgl_getenv()function in your application to retrieve their values. For example, to find out if the Web server supports the HTTPS protocol, add this statement in your application:LET httpsOn = fgl_getenv( "FGL_WEBSERVER_HTTPS" )
How to retrieve web server information in a web service
gwsproxy has already started. The only way to
send the environment is through the HTTP header. Header names set by the GAS have the
following form:
X-FourJs-Environment-Variable-MyHeaderNameWhere
MyHeaderName is the header name. Some variables transmitted by the Web server (Apache, IIS, etc.) are also available to the environment:
X-FourJs-Environment-Variable-REMOTE_ADDRX-FourJs-Environment-Variable-REMOTE_USERX-FourJs-Environment-Variable-SERVER_NAMEX-FourJs-Environment-Variable-HTTPS
- RESTful high-level APIs
-
- Set a
WSHeaderattribute as part of a function parameter. For example,
Or:ip_addr STRING ATTRIBUTE(WSHeader, WSOptional, WSName="X-FourJs-Environment-Variable-REMOTE_ADDR") - Set a context dictionary variable (for example context) at
the modular level with the
WSContextattribute. This allows you to retrieve allX-FourJs-Environment-xxxset by the GAS by referencing a dictionary key value, for example,DISPLAY context["Variable-REMOTE_ADDR"].
- Set a
- Low-level APIs
- With low-level APIs you use the
com.HTTPServiceRequest.getRequestHeader()method. For example:LET param = req.getRequestHeader("X-FourJs-Environment-Variable-REMOTE_ADDR")