With every user action in the browser that results in a call to a Valence instance running on your IBM i Power Server, a wealth of data about the user's session is sent to the integrated Apache Server.  This information can be accessed by your back-end RPG programs to potentially alter how they respond to the front-end. Want to know what URL is on the user's browser page?  Or what type of browser is being used?  All of this and more can be obtained through a simple vvUtility procedure call to access CGI environment variables, and this tip outlines some of the more useful values your programs can retrieve. Each of the items listed below refers to a string to pass into the vvUtility_getEnvVar() procedure, which will return a value that you can assign to a variable within your RPG program --  i.e.: MY_RPG_VARIABLE=vvUtility_getEnvVar('DOCUMENT_ROOT')

  • DOCUMENT_ROOT - Returns the root directory of the server, as defined in your Apache configuration (i.e., /valence-5.0).  Typically this would be the same as the value stored in your Valence settings, returned by vvUtility_getValenceSetting('ROOT_PATH').
  • HTTP_COOKIE - The cookie values passed with the call from the browser.  You can see these in the network traffic of your DevTools console, on the header tab.
  • HTTP_HOST - the hostname of the page being accessed, i.e.  This would be listed as the "Host" in the header of the network traffic.
  • HTTP_REFERER - The full URL of the page, as referenced by the "Referrer" in the header of the network traffic.
  • HTTP_USER_AGENT - the type of browser being used, as referenced in the "User Agent" section of the header.
  • HTTPS - will return "ON" if the site is running through a secure server, otherwise "OFF".
  • QUERY_STRING - the query string being passed to the backend.  This is where most of the values returned from the various VVIN procedures comes from.  Note that this data is encoded in UTF8 so it may need to be converted accordingly within your RPG program, i.e. via vvUtility_convertCCSID(string:1208:0)
  • REMOTE_ADDR - the IP address of the calling entity.  This is the same value returned in the VVCLIENTIP field via vvUtility_getSessVar('VVSESSVAR')
  • REQUEST_URI - the pathname of the requested document or program.  For most Valence calls this will be something like "/valence/vvcall.pgm" but for calls routing outside of portal security it may be something else. Note that like the QUERY_STRING value, the REQUEST_URI is also in UTF8 so it too may need to be converted to a usable CCSID within your RPG program.
  • SERVER_NAME - the server name for your Valence instance, typically the leading portion of the HTTP_HOST, i.e. or myValencePortal, etc.
  • SERVER_PORT - the port number your Valence instance is using, i.e. 7050


CategoryApacheEnvironment VariablesTip of the MonthValence