Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
smartboy #1
Create custom CGI. variable
Does anyone know how I could create a variable that would appear in the #cgi#
scope ? I have x number of coldfusion servers and on each one of them I want
to hard code their names, to get around a number of bugs. When you have debug
info turned on, you see a number of variables, of which I would like to add
my own 'WEBSERVERNAME'. I tried to add a variable to the environment VAR_IST
in the coldfusion start script, but I knew it would work, it it somewhere
in the apache config that I can set it ?? any ideas how to do this ? From a
cfm template id just like to display on the screen #cgi.webservername#
Regards
smartboy Guest
-
Using a Variable to create the SQL Query
I need to create a "dynamic" Update query. I want to store the meet of the command in a variable and then reference the variable in in query. ... -
Create Variable
Hi, I wanted to ask, how can I for Simple Connection component, username text field, set a variable? Thanks Lanex:beer; -
create a dynamic variable
Hi ! i would like to know how to create a dynamic variable with flash. I'm getting 2 strings from XML and would like to create a variable named... -
How do I create a custom stroke?
I want to create a stroke that has a shape on it, ie square block which follow a circle path. How can I do this in Illustrator 10? I can't seem to... -
create variable before redirection.
I'm trying to set a variable before redirection. Here is the code: //header("Location: /ManageProfile.php?UserID=".$id); echo("<input... -
Tomdogggg #2
Re: Create custom CGI. variable
Well, I'm not THAT experienced, but I think your best bet would be to make a
cfswitch clause based on the servers serial number. This is a simple server
variable that you could call, and as long as they all have different serial
numbers; it should work out fine.
The location of the variable is:
Server.ColdFusion.SerialNumber
If you would like to simplify the deployment of this title you'd like to list
on the screen, I would suggest creating a tag like<cf_getServerName> and put
all of your switch/case clauses inside it to set a serverName variable in the
calling page.
Example:
<!---FileName: getServerName.cfm
Purpose: To name the server that content is coming off of.
Location: In the customTags folder on the server
--->
<!---Set the serverSerialNumber variable to the serial number of the server
the tag is running on--->
<cfparam name="serverSerialNumber" default="#Server.Coldfusion.SerialNumber#">
<!---Name the server based on it's serial number--->
<cfswitch expression="serverSerialNumber">
<cfcase value="1st Server's Serial Number Here">
<cfset CALLER.serverName="Name for 1st Server Here">
</cfcase>
<cfcase value="2nd Server's Serial Number Here">
<cfset CALLER.serverName="Name for 2nd Server Here">
</cfcase>
<cfcase value="3rd Server's Serial Number Here">
<cfset CALLER.serverName="Name for 3rd Server Here">
</cfcase>
<cfcase value="4th Server's Serial Number Here">
<cfset CALLER.serverName="Name for 4th Server Here">
</cfcase>
<cfdefaultcase>
<cfset CALLER.serverName="Whatever you want to call the server if it's
serial number hasn't been
listed as a case.">
</cfdefaultcase>
</cfswitch>
Tomdogggg Guest
-
smartboy #3
Re: Create custom CGI. variable
The serial numbers are all differant but I dont really want to use them as the
basis for what im doing. I'd prefer to do this with one line of code and
preferable at application startup. If there was a value that was created at
the startup of the Coldfusion server that was accessible to all cfm templates
that would be great for logging, displaying which server served a template, as
well as a few other simple tasks which can end up being done other ways.
smartboy Guest
-
smartboy #4
Re: Create custom CGI. variable
Is there a way to perhaps add a setting to the cf.registry file (in UNIX) which
I could then call ? eg #server.coldfusion.serialnumber# works fine, could I
add my own value and have say #server.coldfusion.name# ? Obviously somethings
in the registry are accessible, but then some arnt... there must be a simple
way to do this without having to add it to the apache stubb to pass along to
coldfusion...
smartboy Guest
-
Adam Cameron #5
Re: Create custom CGI. variable
> it it somewhere
This sounded like a webserver question to me, so I had a gander at the> in the apache config that I can set it ??
Apache documentation.
1.x
[url]http://httpd.apache.org/docs/mod/mod_env.html#setenv[/url]
2.x
[url]http://httpd.apache.org/docs-2.0/mod/mod_env.html#setenv[/url]
Sounds about right..?
--
Adam
Adam Cameron Guest
-
Tomdogggg #6
Re: Create custom CGI. variable
So then why not just go with the other option I gave? It's simple enough and
sets the name to a server variable and you would just stick the code into an
Application.cfm on each server to make sure the variable exists, and if it
doesn't, it would set it.
It is possible to set a server variable of "server.Name", which will exist
until the server is reset. All you would do to make this one is:
<cflock scope="server" type="readonly" timeout="30" throwontimeout="no">
<cfset IsNamed=IsDefined("server.IsNamed")>
</cflock>
<cfif NOT IsNamed>
<cflock scope="server" type="exclusive" timeout="30">
<cfset server.Name="Server 1, or Server 2, or Server 3, whichever this code
exists on.">
<cfset server.IsNamed=true>
</cflock>
</cfif>
Tomdogggg Guest
-
Adam Cameron #7
Re: Create custom CGI. variable
I actually think this server-scoped option is a better solution than the
requested CGI-variable one. There's "fewer moving parts" as the webserver
is left out of the loop, and the config for a a requirement of your CF app
is handled by CF itself.
Although as long as you're using a CF version post CF5, you can dispense
with all that locking carry-on.
Just have:
<cfparam name="server.server_name" default="SERVERx">
There's no chance for a race condition there, so no need to lock anything
(locking has overhead).
--
Adam
Adam Cameron Guest
-
smartboy #8
Re: Create custom CGI. variable
When you have one file, being accessed from 2 coldfusion servers, behind a load
balanced IP, theres no way to determine which of the two servers generated the
page, using some cfm code to set a variable really doesnt help. Using a
cfexecute to make a system call works sometimes, but often throws memory
errors into the logs as well as a few other strange things. I have tried the
sentenv apache tweak but cant seem to get it to pass it along to coldfusion,
but I think that is the route that will eventually do what I want.
smartboy Guest
-
Adam Cameron #9
Re: Create custom CGI. variable
> When you have one file, being accessed from 2 coldfusion servers,
Fair enough.
The load-balancer might well set a CGI variable of its own here? Depends> behind a load
> balanced IP,
how it's set up. That might be a good palce to do it, if poss. Depends on
how your set-up is configured, of course.
Eek. I wouldn't do that.> page, using some cfm code to set a variable really doesnt help. Using a
> cfexecute
For these reasons.>to make a system call works sometimes, but often throws memory
> errors into the logs as well as a few other strange things. I have tried the
How are you looking for it? One annoying and undocumented quirk I> sentenv apache tweak but cant seem to get it to pass it along to coldfusion,
> but I think that is the route that will eventually do what I want.
discovered regarding CGI variables is discussed (of should that be
"disgust"?) here:
[url]http://www.cfcentral.com.au/cfaussiePosts.cfm?discussion=cfdump%20error%2Fbug% 3F[/url]
The bottom line is don't rely on <cfdump> to tell you all the CGI variables
available, because it doesn't retrieve them all.
However, if you're just doing a <cfoutput> of it, and it ain't there,
then... hmmm, yeah, that's a problem.
If you write a JSP page to dump CGI variables, is it there? Does some a
perl processor or some other script processor ship automatically with
Apache that you can knock together a quick CGI script to dump the CGI
variables and see if the problem lies with Apache or CF? Given the above
thread, I would assume it's Apache, not CF, to be honest.
--
Adam
Adam Cameron Guest



Reply With Quote

