How to set a server-wide variable in ColdFusion -


I have to maintain a variable in my application. (Cfm | CFC) to set up a current environment, environment (development | test | production)

I want to set an environment variable on the server itself, so that I can read the value of it in application.cfm.

Is this possible?

It is easy to set an OS environment variable (run at the system level, or under ColdFusion for the user ), And restart the service variable then available in the CGI scope:

  & lt; Cfset EnvName = cgi.COLDFUSION_ENVIRONMENT & gt; & Lt; Cfoutput & gt; # Envname # & lt; / Cfoutput & gt;  

You can also use Java system properties. In your ColdFusion Administrator, go to "Server Settings / Java and JVM", and add something like "JVM Arguments":

 -Dcom.mycompany.environment = Evolution 

Then you Coldfusion may ask for that value:

  & lt; Cfset System = CreateObject ("java", "java.lang.System") & gt; & Lt; Cfset EnvName = System.getProperty ("com.mycompany.environment") & gt; & Lt; Cfoutput & gt; # Envname # & lt; / Cfoutput & gt;  

The CF service has to be restarted every time you make a change, but the value seems quite stable, so it should not be a problem.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -