Getting Java System Properties in ColdFusion
By Pete Freitag
A while back I wrote some CFML code to dump the Java System Properties, the code went something like this:
<cfset system = CreateObject("java", "java.lang.System")> <!--- properties is a java.util.Properties object ---> <cfset properties = system.getProperties()> <!--- propNames is a java.util.Enumeration ---> <cfset propNames = properties.propertyNames()> <cfoutput> <cfloop condition="propNames.hasMoreElements()"> <cfset propName = propNames.nextElement()> <strong>#propName#</strong> = #system.getProperty(propName)#<br /> </cfloop> </cfoutput>
That works (the code didn't work in until CFMX 6.1, see this post), but I realized today as I wanted to display the results in a table much like the way CFDUMP works - that a java.util.Properties object is a
java.util.Dictionary, and a ColdFusion structure
is a Dictionary
so I can probably CFDUMP a Properties
object. And you can infact CFDUMP a Properties object or any Hashtable, and it will output the values in a table just like a structure. So now I can dump the java system properties in a table with only two lines of code:
<cfset system = CreateObject("java", "java.lang.System")> <cfdump var="#system.getProperties()#">
Getting Java System Properties in ColdFusion was first published on October 29, 2004.
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.
CFBreak
The weekly newsletter for the CFML Community
Comments
This works however the changes don't stay around. Is there anyway to edit and get CF to see the changes? Thanks D
<cfdump var="#CreateObject("java", "java.lang.System").getProperties()#">