Teneo Developers

Using Context Parameters in Teneo Publish Environments

In some cases it can be useful to know explicitly about the environment on which the solution is executing - or to be able to configure parameters differently on different target environments. This could be useful, for example, for having a QA/Dev database and a Prod database, or for logging some information about the actual environment on which the session is running so that it can be used later in session analysis.


The majority of this document is useful for all users who may want to use Context Parameters and is intended to be understandable with little prior knowledge.

The Usage section is a description of how to use this information within the solution once it has been configured on the publish targets. Therefore this part of the document is aimed at Solution Developers who wish to use this information in a solution.

Context Parameters

Unless otherwise stated, this document refers specifically to environments hosted on Tomcat - which is the standard architecture for Teneo Platform Publish Environments. Context Parameters are standard concept in web applications, however the details of how they are configured and the scoping is only verified for Tomcat deployments.

What are they?

Context Parameters are a method of defining on a web container name/value pairs of data which are then available to a web app running within that container. What this means for Teneo is that these parameters, when configured correctly, can be used to be environment-specific values available within a published solution. Once correctly configured the values are available through the Engine API - therefore accessed via solution scripts (examples follow in the Usage section).


As standard, any publish environment will have a single available context parameter release_environment which will have the value of the type of environment to which the solution is published, i.e. "dev"/"qa" /"production". This can then be used within the solution to set up a solution configuration based on the environment type. This means that the solution will behave the same way and have the same configuration on any environment of this type.

This configuration might be:

  • API locations
  • Database connections
  • URL parts for building links in output
  • Authorization provider location

This parameter is available in all solutions published to a standard Web App or pre-configured publication environment with no additional configuration necessary.

Because this is environment-type-specific, it will be the same for all environments of that type so this method does not allow to (for example) distinguish between different targets in a single publish environment, accessible via a load balancer.

Custom Parameters

In a static web application, context parameters are configured within the web.xml file - however, with published Teneo solutions, the web.xml file is generated on each publication and so will be overwritten on each full publish if it is modified on the publication target. This means that in order for the value to be maintained across publication, context parameters must be set in the Tomcat conf/contexts.xml file instead.

This parameter (name and value) will then be visible to all solutions (and any other web applications) deployed to that web container.

These custom parameters could contain:

  • Environment-specific identification for later data analysis (to see loads on particular servers or verify the behavior of individual publication targets)
  • Any of the above release_environment use cases, but where the value varies for different publication targets. For example, if a solution is published to multiple publication targets across the globe and each of these targets has a local database for performance reasons, then the environment type does not give enough information and the specific target environment would be needed to ensure that the data requests go to the correct local data base.



Access to the value of these parameters is through the Engine API within solution scripts.

Engine API

From within any script in the solution calling engineAccess.getProperty('servletContextParameters.release_environment') will get the value of a Context Parameter called "release_environment" if it exists. If it does not exist, the response will be an empty string.

Engine API Reference


1public String engineAccess.getProperty(String _sKey,
2                          String _sDefault)

This returns the value of a specified property as read from the engine property files. If no such property exists, then the given default value is returned. The Java system properties are accessible through the name expression systemProperties.system_property_name.

In the context of the engine web application, the servlet context init parameters and the servlet configuration init parameters are accessible through the name expressions servletContextParameters.parameter_name and servletConfigParameters.parameter_name.


  • _sKey - the name of the property to fetch
  • _sDefault - the value to return if the named property doesn't exist; may be null. (default = "")


  • IllegalArgumentException - if a passed parameter value is null:


1public String engineAccess.getProperty(String _sKey)

The above returns the same value as the invocation of getProperty(_sKey, "").