Skip to main content

Variables

Variables can have a scope of either

  • Request
  • User session
  • Application

For permanent variables user server configurations.

Request variables

Request scope variables should be stored in the Hashtable sharedObjects in the Command object.

Note that the HTTP request parameters are stored in requestParameters.

User session variables

Acces the sessionValues attribute in the Security object

  • boolean hasSessionValue(String name)
  • void setSessionValue(String name, boolean value)
  • int getSessionInteger(String name, int defaultValue)
  • int getSessionInteger(String name)
  • void setSessionInteger(String name, int value)
  • String getSessionString(String name, String defaultValue)
  • String getSessionString(String name)
  • void setSessionString(String name, String value)

All variables her are serilizable and will survive server restarts.

Certain special user properties can also be accessed from the Security object

  • boolean hasProperty(String name)
  • String getProperty(String name)

Finally it is possible to store objects in the Hashtable sessionObjects in the Security object, but be aware that data are transient and will not survive server restarts.

Application variables

Application variables are persistent and accessed through the Command object

Their storage position depends on wether theres is a solution context or not:

  • Solution present: Variables are saved to the solution Configurations
  • None (SagID = 0): Variables are saved to the Static content

Access the the variables goes through get methods with default values.

  • String getConfigurationValue(String name)
  • String getConfigurationValue(String name, String defaultValue)

If the variable does not exist it will be created, and set to the default value (if present).

Note that it is possible to force the use of Statis content by explicitly calling

  • String getSystemConfigurationValue(String name)
  • String getSystemConfigurationValue(String name, String defaultValue)