ColdFusion Tutorial

How to make day-to-day maintenance more trivial.

When you need to test your code locally on localhost or IP 127.0.0.1., it's useful to check if you running on the server or your localhost.
To do this, specify some global variables in the application. The global variables changes depends if you're running on localhost or the server.

Example:

<!--- Application name. --->
<cfset application_name ="ApplayIT">

<!--- Application running on server. --->
<CFIF CGI.REMOTE_HOST NEQ "127.0.0.1">
 <!--- Global variable for the web root. --->
 <cfset request.application.webroot = "
http://#CGI.HTTP_HOST#">
 <!--- Global variable for the images root.  --->
 <cfset request.images.root = "
http://#CGI.HTTP_HOST#/images">
 <!--- Global variable for js files. --->
 <cfset request.js.root = "
http://"&#CGI.HTTP_HOST#&"/"&"common/js/">
 <!--- Global variable for ccs files. --->
 <cfset request.ccs.root = "
http://"&#CGI.HTTP_HOST#&"/"&"common/css/">
<!--- ********************************************* --->
<cfelse>
 <!--- Application running on localhost 127.0.0.1 --->
 <!--- Global variable for the web root. --->
 <cfset request.application.webroot = "
http://#CGI.HTTP_HOST#/#application_name#">
 <!--- Global variable for the images root.  --->
 <cfset request.images.root = "
http://#CGI.HTTP_HOST#/#application_name#/images">
 <!--- Global variable for js files. --->
 <cfset request.js.root = "
http://"&#CGI.HTTP_HOST#&"/"&#application_name#&"/common/js/">
 <!--- Global variable for ccs files. --->
  <cfset request.ccs.root = "
http://"&#CGI.HTTP_HOST#&"/"&#application_name#&"/common/css/">
</cfif>

How to use this in your code:

<a href="<cfoutput>#request.application.webroot#</cfoutput>/index.cfm/fuseaction/about.information/information.cfm" onFocus="if(this.blur)this.blur()"><img src="<cfoutput>#request.images.root#</cfoutput>/information_button.gif" alt="Information about ApplayIT, services and products." width="30" height="23" border="0"></a>

 

ColdFusion Tutorial test

How to make day-to-day maintenance more trivial.

No test is available or implemented for this ColdFusion Tutorial.

User Comments: 2

 The use of &?/?

The use of "& &" is adding words to a string.

Example:
This is my string&?/?

Will add a / at the end of the string.
This is my string/

 Question?

What is the use of "& &" in this line?
<cfset request.ccs.root = "http://"&#CGI.HTTP_HOST#&"/"&#application_name#&"/common/css/">

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
A6m
Your IP Address: 38.103.63.62
 

ScandicWeb is own by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.

[Home [Site Map [Privacy Statement [Site Feedback] [About ScandicWeb]


[ColdFusion [Flash [Search Engine Optimization [Graphics [Cascading Style Sheets (CSS) [JavaScript (JS) [Software]

Partner sites: ScandicSoft


Server time: 19. November 2008 Wednesday