" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi

How to get database table ColumnList from a query resultset in ColdFusion?

Posted on November 23rd, 2015 by Sankalan Panda

One Sample CFQUERY <cfquery name=”myQuery” datasource=”yourDataSourceName” result=”myResult”> select * from tableName </cfquery> To get the column names in alphabetical order (NOT in same order as in database table) <cfoutput> #myQuery.ColumnList#<br> #myResult.ColumnList# </cfoutput> To get the column names in the same order as in database table, we can use this: <cfoutput> #ArrayToList(myQuery.getColumnList())# </cfoutput>   This tip […]

How to protect ColdFusion CFM templates from Cross Site Scripting attacks?

Posted on November 23rd, 2015 by Sankalan Panda

Perhaps the easiest attack that is possible on a web page is Cross Site Scripting attack. Attackers can easily “view source” the web page and save it on local box. They can easily manipulate the page content, change the POST ACTION link and can easily penetrate into your CFM templates. However, restricting Cross Site Scripting attacks […]

StructCopy() VS Duplicate()

Posted on November 23rd, 2015 by Sankalan Panda

StructCopy() and Duplicate(), both the ColdFusion functions can be used to clone a ColdFusion structure. But the important point to note here is- StructCopy(): Creates a clone of the structure by reference (clones top level keys and values by value and nested structures by reference) Duplicate(): Creates a clone of any type of objects (that […]

How to track whether the recipient has opened/read the email or not?

Posted on November 23rd, 2015 by Sankalan Panda

We can send emails with ColdFusion using cfmail tag, but we do not have a direct way to track whether an email has been read/opened by the recipient or not. We can do this using some indirect way mentioned below. While developing an email functionality with cfmail, we can include one 1X1 px image in […]

Connect to MySQL 4.1 or any higher version MySQL database from ColdFusion 7 script

Posted on November 23rd, 2015 by Sankalan Panda

From ColdFusion if we need to connect to any database then we need to create datasource in ColdFusion server administrator. When we need to create datasource in ColdFusion 7 admin to connect to MySQL 4.1 or any higher MySQL version database we need to use the default MySQL Driver (from the list of driver options provided by […]

Access/Modify ColdFusion Administrator settings programmatically by ColdFusion Administrator API calls

Posted on November 23rd, 2015 by Sankalan Panda

Usually if we need to do some setting changes for ColdFusion application server then we log into ColdFusion Administrator using ColdFusion Admin GUI and change the settings. We can also do all the ColdFusion Administrator setting changes programmatically through ColdFusion Administrator API calls. ColdFusion provides us with around 12 components for different sections of the Administrator. […]

Application.cfm / Application.cfc (V1)

Posted on November 23rd, 2015 by Sankalan Panda

Few important tips and notes about Application.cfm/cfc: This is the first ColdFusion file that gets executed by the ColdFusion Application server even if we request for some other file. Example: When we type http://www.mySite.com/index.cfm, Application.cfm/cfc gets executed first and then index.cfm. Application.cfc/cfm and all objects gets instantiated for each server page request. We may or […]

How and why we should avoid white space while creating XML objects in ColdFusion

Posted on November 23rd, 2015 by Manisa Pattanaik

We have two ways (basically two CF tags) in ColdFusion to create XML objects, they are <CFSAVECONTENT> and <CFXML> Example: <cfxml variable=”xmlData”> <?xml version=”1.0″ encoding=”UTF-8″?> …… </cfxml> <cfsavecontent variable=”xmlData”> <?xml version=”1.0″ encoding=”UTF-8″?> ……. </cfsavecontent> If we will pass these XML objects to the XML parser using “XmlParse()” function we will get an error. ERROR:  “The […]

MX CF 7, CFQUERYPARAM AND HANDLING NULLS

Posted on November 23rd, 2015 by Saroj Sahu

We use cfqueryparam in query parameters to secure database from malicious and un-authorized users (through SQL injection), perform data validation and get benefits of sql-bind property. We use cfqueryparam whether we do INSERT, UPDATE, DELETE OR SELECT. One problem we might face when we have a column with INT, TIMESTAMP datatype and the column is […]

Creating datasource for MSSQL 2000 in ColdFusion 8

Posted on November 23rd, 2015 by Rajashree Mishra

From ColdFusion if we need to connect to any database then we need to create datasource in ColdFusion administrator. In ColdFusion 8 administrator we have a database connection driver for “SQL server”. Before creating datasource we would need to check the Service Pack for SQL 2000. In order to successfully create the datasource for SQL […]

How to resolve resource (CSS, Image) embedding problems?

Posted on November 23rd, 2015 by Saroj Sahu

Details: CFDOCUMENT tag in ColdFusion can be used to create PDF output from a text block containing CFML or HTML. We use images and styles to be embed into the PDF through HTML. Sometimes while trying to embed images and styles to the PDF, we may face issues like, “Invisible images”, “Styles not reflecting”, etc., […]

Embed images in emails using ColdFusion

Posted on November 23rd, 2015 by Debjani Mallick

Description: Normally when we send an image through an email, we send it either as an attachment or external link. In addition to these two we have one more way to do the same in ColdFusion, i.e. sending embedded images in an email.Further Details: Using CFMAIL tag attributes we provide all the details for sending […]

CFQUERY bug on using different datasources within a single query

Posted on November 23rd, 2015 by Swastik Sen

Recently, I encountered an interesting bug in CFQUERY. Here is an example with detailed explanation. <cfquery name=”GetParks” datasource=”MYSQLdsn”> SELECT parkname, region, state FROM Parks <!— checks the return value (boolean) of function —> <cfif countRecord()> ORDER BY parkname, state </cfif> </cfquery> If we call an UDF named countRecord() from within a CFQUERY, and that query uses […]

Add Mapping to Coldfusion Admin Dynamically

Posted on November 23rd, 2015 by Upendra Roul

Using this tip we can add mapping variables to the coldfusion server dynamically as follows. <cfscript> //”/MyMap” is the name of the mapping variable mapping = “/MyMap”; serviceFactory = createObject(“java”,”coldfusion.server.ServiceFactory”); mappings = serviceFactory.runtimeService.getMappings(); //Shows all the mapping variables of the server before setting writeDump(mappings); //If the mapping variable is not present then create it if(not(structKeyExists(mappings, […]

How to use a Java Bean in a ColdFusion page?

Posted on November 23rd, 2015 by Aditya Moharana

Following steps are to be followed:- 1.Write a Java program that does not contain main method. 2.Complile the java program into .class file(for that you need to install jdk and do the necessary settings) 3.Put the .class file in web_root/WEB-INF/classes(i.e the default class path set in JVM by CF admin). If you want to place […]

Coldfusion|Making a call to a Web Service with complex object as input parameter

Posted on November 23rd, 2015 by Rajashree Mishra

In order to pass a custom object type as input parameter to a webservice in ColdFusion we need to do following steps.   [A custom object type can be created in .NET or Java, which used tobe defined in the .xsd file referenced from wsdl. For example we are using a type ‘MyObjectType’ in a webservice call here.] […]

Creating a database conection object in Coldfusion

Posted on November 23rd, 2015 by Sonu Agarwal

In my current project ,I came across a situation where I had to create a database conection object in coldfusion and  passed it  to the java  class which further make a database query using that conection object.   Initially,I downloaded the required jar file which was in my case ojdbc5.jar and placed it to C:\ColdFusion9\lib […]

Bug in script version of cfquery

Posted on November 23rd, 2015 by Upendra Roul

We generally use ColdFusion tags in our coding. But sometimes we prefer to use script version of that, instead the tag. Also in ColdFusion 9.0.1 have a script version code for almost every tags. In ColdFusion 9.0.1 the script version of cfquery has a bug as follows. Let our table name is “USERS(USER_ID, FIRST_NAME, LAST_NAME, […]

How to refresh Captcha image

Posted on November 23rd, 2015 by Deepak Kumar

Captcha images are very helpful in preventing spammers posting form data into our applications . A captcha image is a image having some distorted text which humans can read but not computer programs. It is a type of test that essures that the response is generated by a person. In coldfusion captcha images can be […]

Batch Processing In ColdFusion

Posted on November 23rd, 2015 by Rajashree Mishra

‘Batch Processing’.. The name itself explains that some job is done in a batch (phase wise). Normally when we have requirement of populating data base table from some external source (may be XML or excel sheet), we do loop with the data that to be inserted into specified data base table. If the data is […]

Use of ‘URL Rewriting’ in Web Application

Posted on November 23rd, 2015 by Pausali Sanyal

The purpose of writing this tip is that somedays before I  was almost lost in my current project. It was miserable for me to find out how  and where a particular event is fired to execute a particular functionality  though it was understandable that the event was fired because whenever I changed  something in the […]

While working with AJAX ColdFusion Debugging may break your Ajax calls

Posted on November 23rd, 2015 by Abhisek Das

In one of my recent project, at most of the occasions I was using Ajax and ColdFusion CFC to get the records from DB. But in some cases, in my local development server, I was facing some problems, while in the production server all were working fine. The difference I found only that I had […]

Query of query inside CFSCRIPT

Posted on November 23rd, 2015 by Subodh Mishra

Query of Queries: A Query that retrieve query object from a recordset is called Query of Queries. For more details on this read this link Query of Queries. In my project I needed this feature and throughout application I am using CFSCRIPT tag to write server side coding. So for Query of Query first I […]

Install ColdFusion 9 and 10 on same machine

Posted on November 23rd, 2015 by Subodh Mishra

How to install ColdFusion 9 and 10 on same machine (on windows 7) ColdFusion 10 is out and most of the developers want to gets their hands dirty with ColdFusion 10. As well as they want to check their code compatibility with ColdFusion 10 also. So the basic thing is to install the ColdFusion 10 […]

Hide/Show columns

Posted on November 23rd, 2015 by Subodh Mishra

CFgrid is the one of the most coolest ajax feature provided by coldfusion. Here i have used a static Cfgrid to explain how we can hide and show the cfgrid columns. comments are self explainatory <cfscript> //Declare and define the Sql query VARIABLES.myQuery = “SELECT FIRSTNAME,LASTNAME,ADDRESS,CITY FROM ARTISTS”; //Store the Query Result into a variable […]

Customizing FCK Editor in ColdFusion

Posted on November 23rd, 2015 by Dipak Panda

The content is all about customizing FCKEditor that is well integrated with ColdFusion. The content is all about customizing FCKEditor that is well integrated with ColdFusion. We have an editor known as FCKEditor to edit HTML content. We can use this editor by use of cftextarea in our Application. This gives us a complete set […]

Access an Web Service from a SSL enabled Website

Posted on November 23rd, 2015 by Aditya Moharana

If you want to access an web service from a website which is SSL enabled (used HTTPS), you have to download SSL certificate from the SSL enabled website and install that on the application server. Here I have written procedure to download the SSL certificate from Mozilla Firefox and Internet Explorer and Google Chrome. N.B:You […]

How to access ColdFusion administrator properties

Posted on November 23rd, 2015 by Chandrakanta Behera

Different ways to access and work on CF administrator properties. This is obvious that there several ways to access CF administrator properties, but How !! Find these below. The simple one …. Just can go and open administrator from adobe in installed programs (start menu – adobe). Else can open it on browser.. http://<host-name> : […]

How to append “www” to your site domain using ColdFusion?

Posted on November 23rd, 2015 by Dipak Panda

Some times it becomes important to add “www” to your site domain. There might be many more reasons to do so. I am just citing one example. Site name “domain.com” and “www.domain.com” are assumed to be two different sites by Google search engine robots. This will result in display of duplicate search results for your […]

How to create dynamic variables in ColdFusion?

Posted on November 23rd, 2015 by Dipak Panda

At times during coding in Coldfusion, we get stuck at places, where we need to create variables dynamically. We may attempt with below code to create dynamic variables. <!— Here I am trying to create dynamic variables. —> <cfloop from=”1″ to=”10″ index=”variables.counter”> <cfset variables.employee#variables.counter# = variables.someValue> </cfloop> Here I am expecting to create variables as […]

How to stop access to any particular folder files in ColdFusion

Posted on November 23rd, 2015 by Dipak Panda

Sometimes it becomes necessery to stop access/browsing to files of any particular folder. For example, you can think of an upload folder. Here any body can upload a file and then can browse it to run its intended code. There might be many situations like this, where there is a strict requirement to stop access […]

How to escape single quote(‘) or double quote(“) in ColdFusion?

Posted on November 23rd, 2015 by Dipak Panda

At times while coding in ColdFusion and working with strings, it becomes a headache to escape single or double quotes with in a string. For this we may use below written way to manage. <cfset variables.event = “Hari’s first pen.” /> OR else <cfset variables.event = ‘Hari is 5″ tall.’ /> Both the above ways […]

The easy way to compare two lists in ColdFusion

Posted on November 23rd, 2015 by ColdFusion

While it comes to comparing two lists in ColdFusion, there is no predefined functions or tags to do so. We can think of one way of doing so as below. Usual way of doing: <!— Two strings to match —> <cfset variables.list1 = ‘200,234,355’> <cfset variables.list2 = ‘355,200,234’> <!— Flag to check matched —> <cfset […]

Manage Query Caching In ColdFusion Separately

Posted on November 23rd, 2015 by Dipak Panda

Caching has been used for years to improve performance of applications. So it is very much important to control caching properly to get highest possible benefit out of it. Please find the method below to manage query caching properly. First I will demonstrate the logic and then follow it up with code. The problem with […]

How to write ColdFusion error log file in cfscript

Posted on November 23rd, 2015 by Yadagiri Talada

I would like to share a small TIP which may help you all in recording errorLog in text file. I have written a piece of code like – ************************************************************ <cfscript> // File to write the error log // file_to_search = ‘c:\testFile.txt’; // Details about the error to log // savecontent variable=”data” { WriteOutput(‘<br />’ & […]

How to check session timeout through AJAX call?

Posted on November 23rd, 2015 by Dipak Panda

Now a day most of the applications are running on AJAX. We are making huge use of AJAX to provide rich internet experience. Think of a situation, where your application is password protected. For each http request we make to server, it is being checked against session existence. If session has been expired then the […]

Convention of the ColdFusion component inside CFSCRIPT

Posted on November 23rd, 2015 by Snehanjali Sahoo

Generally, we use the following convention to write the method within CFSCRIPT : <cfscript> component displayname=”DemoModel” hint=”Contains the demo functions” output=”false” { public struct function DemoFun(string arg1, numeric arg2) hint=”This is a demo function” { //Do the operation } } </cfscript>   But, for writing the methods within the CFSCRIPT , we do not need […]

ColdFusion Beginner Tip. When to use and not to use # in your cfcode.

Posted on November 23rd, 2015 by Ashish Jhanwar

I have seen many beginners confused over the use of # sign in ColdFusion and most are so confused that they use it anywhere they can! I have been asked this question so many times, that I decided to write about it. The basic thing you need to remember about using # in ColdFusion is […]

Copying Structures in Coldfusion

Posted on November 23rd, 2015 by Ashish Jhanwar

Coldfusion has the feature of creating structures which is a JSON like key-value pair variable, essentially used to store multiple variables as a single collection. There are different ways to copy structures in coldfusion and there are differences between them as well. Following are some of the ways in which one can copy structures in […]