[Looking for Charlie's main web site?]

Did you know that CF2018 imports environment vars into the Server scope?

This is a hidden gem that I never saw documented anywhere: CF2018 now imports environment variables into the CF "server" scope, specifically:


and java system properties into:


(Thanks to Sean C for catching a mistake in the initial post.)

I learned of it last year when Pete F tweeted about it, and I assumed someone else would do a post about it, but the topic came up in a discussion today and I was surprised to not be able to find any mention of it, other than that and his mention of it in his cfdocs.org site.

And yes, Lucee had it first (as proposed initially in 2015). :-)

The feature can be useful, whether you're setting such vars when running a (Docker) container, or via JVM args, etc., and you want to be able to access them within CFML.

For more content like this from Charlie Arehart: Need more help with problems?
  • If you may prefer direct help, rather than digging around here/elsewhere or via comments, he can help via his online consulting services
  • See that page for more on how he can help a) over the web, safely and securely, b) usually very quickly, c) teaching you along the way, and d) with satisfaction guaranteed
server.system.properties is the JVM system properties -- not environment variables.

server.system.environment is the environment variables.

(the cfdocs.org site gets this right by the way)
# Posted By Sean Corfield | 2/28/20 4:58 PM
Thanks, Sean. I was running out the door as I wrote that, so got sloppy. I have corrected it, and acknowledged your helpful clarification.
# Posted By charlie arehart | 2/28/20 5:03 PM
I had totally missed this being added to CF2018 (or Lucee 5, since I stopped following Lucee a few years back). It's nice to have both environment variables and properties available in server scope but it's really easy to get at them via Java interop.

An important difference is that programs cannot change environment variables but they can modify/add system properties (using java.lang.System/setProperty).

It's also important to observe that although you can assign to server.system.properties and server.system.environment, those do not affect the actual environment or properties available via Java.

A final, equally important observation is that if a program changes properties while it is running (via setProperty() above), the server data structure does not reflect those change!

p.s. I don't see the updates on the blog post yet!
# Posted By Sean Corfield | 2/28/20 5:17 PM
Ah, now I see the update.
# Posted By Sean Corfield | 2/28/20 5:18 PM
Thanks for all the additional info. I suspect others may have still more to share. Happy to have this be a place to track such things, them maybe some info could be added to either cfdocs.org, or the cf docs, or both. :).
# Posted By Charlie Arehart | 2/28/20 5:24 PM
Copyright ©2022 Charlie Arehart
Carehart Logo
BlogCFC was created by Raymond Camden. This blog is running version 5.005.
(Want to validate the html in this page?)

Managed Hosting Services provided by
Managed Dedicated Hosting