Entries Tagged as 'ColdFusion'

Coldfusion interview Questions with answers Part 6

ColdFusion No Comments »

101. What is the difference between cfabort, cfexit, cfbreak
  Cfbreak:
    * Used within a cfloop/cfswitch tag used to break out of a loop/switch block.
  Cfabort:
    * Stops the processing of a ColdFusion page at the tag location.
  Cfexit:
    * cfexit returns control to the page that called that custom tag, or in the case of a tag called by another tag, to the calling tag.
    * If cfexit is used outside a custom tag, it functions like a cfabort.

102. What is the difference between cfset, cfparam?
CFparm only writes to the variable if the variable does not exist.
CFSet overwrites the variable with a new value regardless of if it exists.

103. How can you implement cfparam into cfscript?
Tag Version:
 <cfparam name="variableName" default="defaultValue">
Script Version:
 <cfscript>
  if(Not isDefined('variableName'))
    variableName = "defaultValue"
 </cfscript>

104. What is the use of cfcookie expires attribute? What is the default value for the same?
It defines lifetime or scope of a cookie variable.
expires attribute is optional attribute for cfcookie tag.Default value is till the browser is closed.If you didn't mention the expires attribute for an cookie variable it will available upto browser close.

105. What is the difference between cfquery & cfinsert/cfupdate
CfQuery
   * Safer for SQL injection attack
   * Can do any sql operations
Cfinsert/Cfupdate
   * Designed to do one thing and one thing only
   * Only work with FORM fields
   * FORM fields be named the same as the table columns
   * Cannot do any processing or manipulation of the values
   * When updating the row primary key must be present as a FORM field (possibly as a hidden field).
   * If you are using CFCs as a database abstraction layer then you can't use cfinsert/cfupdate

106. cfquery/cfstoredproc Which is good for stored proc call?
To execute a stored procedure, you can use either the <cfquery> or <cfstoredproc> tag. Each has its own advantages and disadvantages.
cfquery :
      * simple to use
      * Maximum flexibility in terms of creating dynamic sql for the query
cfstoredproc :
      * It provides support for multiple record sets returned from a stored procedure, meaning that you can create more than one record set from the same procedure.
      * Some variables, such as the status code that is created when the tag is called, are not available through cfquery.

107.What is the use of cfsetting?
This tag used to Control the requested URL's page processing, such as the output of HTML code in pages.It has 3 attributes.
  * enableCFoutputOnly
  * requestTimeOut
  * showDebugOutput
All are optional attributes. you should mention atleast one attribute.Here I will explain a bit about requestTimeOut attribute.Rest two explained for the next question.
     This attribute added in ColdFusion MX varsion.
     It used to define time limit, after which ColdFusion processes the page as an unresponsive thread.
    Overrides the time-out set in the ColdFusion Administrator.

108. Explain about enableCFoutputOnly, showDebugOutput attributes of cfsetting tag
enableCFoutputOnly    
    * yes: blocks output of HTML that is outside cfoutput tags.
    * no: displays HTML that is outside cfoutput tags.
showDebugOutput
    * yes: if debugging is enabled in the Administrator, displays debugging information.
    * no: suppresses debugging information that would otherwise display at the end of the generated page.

Coldfusion interview Questions with answers Part 5

ColdFusion No Comments »

85. How can you connect with database from Coldfusion?
      Database manipulation tags (cfquery, cfstoredproc, cfinsert, cfupdate) have an attribute called datasource which used to identify/connect to a database.
      Data sources can be defined in CF administrator section.

90. How can you create Tab strip?

    Coldfusion introduced easy to use AJAX UI elements. cflayout and cflayoutarea tags used to create tab strips.

<cflayout type="tab">
    <cflayoutarea title="Tab 1">
        I am normal tab content
    </cflayoutarea>
    <cflayoutarea title="Tab 2" selected="true">
        This tab selected at page load
    </cflayoutarea>
    <cflayoutarea title="Tab 3" disabled="true">
        you can't see me, bcz I am in disabled tab
    </cflayoutarea>
    <cflayoutarea title="Tab 4" closable="true">
        U can kill :) (close) me
    </cflayoutarea>
</cflayout>

91. What is Flash form?
     Flash form is a form like ordinary HTML form, with flash format which run on flash player enabled browsers.
     Using cfform tag CF automatically generates the swf format form's Flash binary from your CFML code.
     Flash Forms can be used to create a better forms experience for your users.
     These features include accordion-style and multiple-tab form panes and automatic element positioning.
     You can also display cftree, cfgrid, and cfcalendar form elements as Flash

92. How can you show the report in PDF?
CF Report builder is professional reporting tool coming with CF. CF 8.0.1 contains build in report builder.
In earlier releases, this report builder available as separate installable. You can find the downloads below URL
http://www.adobe.com/support/coldfusion/downloads_updates.html
There have been many software packages that offer these types of solutions, including Crystal Reports, Actuate
CFReport tag used to integrate the Report builder templates into HTML & Pdf reports. Format attribute of cfreport tag used to show the reports into PDF.

<cfreport template="userList.cfr" query="users" format="PDF" title="Sales Department Employees" />

93. What is SaveContent?
Used to save the generated content to a variable, including the results of evaluating expressions and executing custom tags.
This tag requires an end tag.
Main usage of savcontent is cache partial pages.

94. What is CFFlush?
The first occurrence of this tag on a page sends back the HTML headers and any other available HTML. Subsequent cfflush tags on the page send only the output that was generated after the previous flush.
When you flush data, ensure that enough information is available, as some browsers might not respond if you flush only a small amount. Similarly, set the interval attribute for a few hundred bytes or more, but not thousands of bytes.
Use the interval attribute only when a large amount of output will be sent to the client, such as in a cfloop or a cfoutput of a large query. Using this form globally (such as in the Application.cfm file) might cause unexpected errors when CFML tags that modify HTML headers are executed.
Caution: Because the cfflush tag sends data to the browser when it executes, it has several limitations, including the following: Using any of the following tags or functions on a page anywhere after the cfflush tag can cause errors or unexpected results: cfcontent, cfcookie, cfform, cfheader, cfhtmlhead, cflocation, and SetLocale. (These tags and functions normally modify the HTML header, but cannot do so after a cfflush tag, because the cfflush sends the header.) Using the cfset tag to set a cookie anywhere on a page that has a cfflush tag does not set the cookie in the browser. Using the cfflush tag within the body of several tags, including cfsavecontent, cfquery, and custom tags, cause errors. If you save Client variables as cookies, any client variables that you set after a cfflush tag are not saved in the browser.
Note: Normally, the cferror tag discards the current output buffer and replaces it with the contents of the error page. The cfflush tag discards the current buffer. As a result, the Error.GeneratedContent variable resulting from a cferror tag after a cfflush contains any contents of the output buffer that has not been flushed. This content is not sent to the client. The content of the error page displays to the client after the bytes that have been sent.

95. What is the difference between HTMLEditFormat and HTMLCodeFormat?
    Both are used to replaces special characters in a string with their HTML-escaped equivalents
    Difference between HTMLCodeFormat function and HTMLEditFormat is that HTMLEditFormat does not surround the text in an HTML pre tag

96. What is URLFormat?

Part A:
  This is simply the http path to your server and the directory.
  It contains 3 components,
     The protocol to use to retrieve the object. (Eg, Http, Https)
     DNS name or an IP address Web server
     The host machine port on which the Web server is running. If omitted, the specified protocol's default port is used; for Web servers, this port is 80.
Part B:
  This is the name of application or file to retrieve or the script to execute
Part C:
  This is the most important part of the URL also known as the query string.
  It is started by the question mark "?".
  Individual parameters, are separated by the ampersand "&".

97. What is CFAbort?
Stops the processing of a ColdFusion page at the tag location.
ColdFusion returns to the user or calling tag everything that was processed before the cfabort tag.
You can optionally specify an error message to display using showError attribute.
The tag is often used with conditional logic to stop processing a page when a condition occurs.

98. What is the difference between CFAbort and CFBreak?
Please see Answer:101

99. What is CFQueryparam? What is the use?
It separates parameters from the surrounding SQL.
It allows the database’s SQL analyzer to more efficiently handle the SQL statement
It validates data for the parameters which used to avoid SQL injection attacks.
One limitation of cfqueryparam in earlier versions.
 you can’t use the cachedwithin or cachedafter attributes of the cfquery tag when using the cfqueryparam tag.
 CF 8 will allow this

100. How can you create dynamic query?
   Dynamic SQL is a SQL code that your program generates using variables before the SQL is executed.
   In coldfusion, CFQUERY give full provision to write all conditional logic & looping to derive the dynamic sql statement to execute.

   You can use dynamic SQL to accomplish tasks such as adding WHERE clauses to a search based on the fields that the user filled out on a search criteria page.

Coldfusion interview Questions with answers Part 3

ColdFusion No Comments »

41. What is CFInclude?
Cfinclude is like substituting a block of code in the page where you are putting the cfinclude tag. The variables in the called page will have the same scope as in the calling page.

42. What is CFModule?
Cfmodule is really a custom tag call. It is, in fact, a way to call a custom tag without needing to place it in the "customtags" folder, or in the same folder as the calling process.

44. What is the difference between Custom tag and Coldfusion Component?
    Custom tags have a single entry point; CFCs can have multiple entry points. This makes it possible to create a single component that does many related actions. (To do that with custom tags you'd need multiple tags or cumbersome switch processing.)
    Custom tags have no formalized parameter passing and validation mechanism; CFCs do. In other words, unlike custom tags, CFCs can validate passed data, enforce data types, check for required parameters, and optionally assign default values.
    Custom tags cannot persist; CFCs can. Custom tags are blocks of code that are executed as is, while CFCs are objects and can be treated as such.
    Custom tags are designed to contain code; CFCs are designed to contain both code and data.
    Custom tags are accessible only by ColdFusion and only locally; CFCs can be accessed as web services, opening up a whole new world of reuse possibilities.

45. What is CFX tag? What is the use?
The CFX interface is the original ColdFusion extensibility interface. It is fast and powerful, and allows for tags to be written in Java or in C/C++. CFX tags are executables that must be registered in the ColdFusion Administrator so as to bind an alias with the name of the actual executable. Using the CFX interface, it is possible to write extensions that cannot be written using other interfaces.

46. What is Coldfusion component?
ColdFusion Components are essential building blocks used in creating tiered, structured, and scalable applications. Unlike Custom Tags, which are primarily used to encapsulate processing, and UI abstractions, ColdFusion Components are designed to black-box processing, transactions, back-end integration, and the like.

48. How can you invoke CFC?
Method 1:

<cfinvoke>
    <cfinvoke component="user" method="Get" returnvariable="usr">
    <cfinvokeargument name="id" value="#id#">
</cfinvoke>

Method 2:

<!--- Load CFC as an object --->
<cfobject component="user" name="userObj">
<!--- Invoke method --->
<cfinvoke component="#userObj#" method="Get" id="#id#" returnvariable="usr">

Method 3:

<cfscript>
// Load CFC as an object
userObj=CreateObject("component", "user");
// Invoke method
user_id=userObj.Get(id);
</cfscript>

Method 4: URL Invocation
CFCs can also be invoked on the command line directly; every CFC has a URL that points to it. When invoking CFCs via URLs, the method and any arguments are passed as URL parameters, as seen here:
http://localhost/users/user.cfc?method=get&id=1

50. What are the different ways to access CFC?
Same as 48

51. What is CFobject?
CFC can be instantiated as an object, using the <cfobject> tag.

52. What is CreateObject?
CreateObject() is a functional equivalent of the <cfobject> tag. CreateObject() can be used to instantiate CFCs just like <cfobject> can, but there is one notable difference: As a function, CreateObject() can be used in a <cfscript> block (whereas <cfobject> cannot).

56. How can you call the external exe files?
using cfexecute tag, we can call the external exe files.Below example executes the Windows NT version of the netstat network monitoring program, and places its output in a file.
<cfexecute name = "C:\WinNT\System32\netstat.exe"
arguments = "-e"
outputFile = "C:\Temp\output.txt"
timeout = "1">
</cfexecute>

57. What is cfexecute? What are the attributes? What is the drawback of using this?
CFExecute is a tag used to execute developer-specified process on server computer. It has some restrictions like; it cannot run in windows 2003 and cannot run a batch file.

AttributeDescription
name Absolute path of the application to execute. On Windows, you must specify an extension, for example, C:\myapp.exe.
arguments Command-line variables passed to application. If specified as string, it is processed as follows:
* Windows: passed to process control subsystem for parsing.
* UNIX: tokenized into an array of arguments. The default token separator is a space; you can delimit arguments that have embedded spaces with double-quotation marks.
If passed as array, it is processed as follows:
* Windows: elements are concatenated into a string of tokens, separated by spaces. Passed to process control subsystem for parsing.
* UNIX: elements are copied into an array of exec() arguments.
outputFile File to which to direct program output. If no outputfile or variable attribute is specified, output is displayed on the page from which it was called.
If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function.
timeout Length of time, in seconds, that ColdFusion waits for output from the spawned program.
* 0: equivalent to nonblocking mode.
* A very high value: equivalent to blocking mode.
If the value is 0:
* ColdFusion starts a process and returns immediately. ColdFusion may return control to the calling page before any program output displays. To ensure that program output displays, set the value to 2 or higher.
* If the outputFile attribute is not specified, any program output is discarded
variable Variable in which to put program output. If no outputfile or variable attribute is specified, output is displayed on page from which it was called.

58. What is WDDX? Where all are applicable?
For XML to work, both sender and recipient must agree on an XML language, and all data must be well formed according to that language. WDDX is Macromedia's contribution to the XML community. It is an open-source XML DTD (Document Type Definition) that defines generic data types such as strings, arrays, structures, and recordsets. WDDX is an XML language that defines data not any specific implementation, but raw data itself. This can make data sharing via XML quick and painless (it doesn't require that an XML language be agreed upon).

Coldfusion interview Questions with answers Part 2

ColdFusion No Comments »

21. What is Scope Variables?
A variable's scope is determined by its origin. The scope determines a number of properties about the variable, such as its life span, timeout, and storage location, and therefore, how it can be used.

22. What is the different type of Scope variables?

Scope Description
Application Contains variables that are associated with one, named application on a server. The cfapplication tag name attribute or the Application.cfc This.name variable setting specifies the application name.
Arguments Variables passed in a call to a user-defined function or ColdFusion component method.
Attributes Used only in custom tag pages and threads. Contains the values passed by the calling page or cfthread tag in the tag's attributes. 
Caller Used only in custom tag pages. The custom tag's Caller scope is a reference to the calling page's Variables scope. Any variables that you create or change in the custom tag page using the Caller scope are visible in the calling page's Variables scope.
CGI Contains environment variables identifying the context in which a page was requested. The variables available depend on the browser and server software.
Client Contains variables that are associated with one client. Client variables let you maintain state as a user moves from page to page in an application, and are available across browser sessions. By default, Client variables are stored in the system registry, but you can store them in a cookie or a database. Client variables cannot be complex data types and can include periods in their names.
Cookie Contains variables maintained in a user's browser as cookies. Cookies are typically stored in a file on the browser, so they are available across browser sessions and applications. You can create memory-only Cookie variables, which are not available after the user closes the browser. Cookie scope variable names can include periods.
Flash Variables sent by a Flash movie to ColdFusion and returned by ColdFusion to the movie.
Form Contains variables passed from a Form page to its action page as the result of submitting the form. (If you use the HTML form tag, you must use method="post".)
function local Contains variables that are declared inside a user-defined function or ColdFusion component method and exist only while a function executes.
Request Used to hold data that must be available for the duration of one HTTP request. The Request scope is available to all pages, including custom tags and nested custom tags, that are processed in response to the request. This scope is useful for nested (child/parent) tags. This scope can often be used in place of the Application scope, to avoid the need for locking variables. Several chapters discuss using the Request scope.
Server Contains variables that are associated with the current ColdFusion server. This scope lets you define variables that are available to all your ColdFusion pages, across multiple applications.
Session Contains variables that are associated with one client and persist only as long as the client maintains a session. They are stored in the server's memory and can be set to time out after a period of inactivity.
This Exists only in ColdFusion components or cffunction tags that are part of a containing object such as a ColdFusion Struct. Exists for the duration of the component instance or containing object. Data in the This scope is accessible from outside the component or container by using the instance or object name as a prefix.
ThisTag Used only in custom tag pages. The ThisTag scope is active for the current invocation of the tag. If a custom tag contains a nested tag, any ThisTag scope values you set before calling the nested tag are preserved when the nested tag returns to the calling tag. The ThisTag scope includes three built-in variables that identify the tag's execution mode, contain the tag's generated contents, and indicate whether the tag has an end tag. A nested custom tag can use the cfassociate tag to return values to the calling tag's ThisTag scope.
Thread Variables that are created and changed inside a ColdFusion thread, but can be read by all code on the page that creates the thread. Each thread has a Thread scope that is a subscope of a cfthread scope.
thread local Variables that are available only within a ColdFusion thread.
URL Contains parameters passed to the current page in the URL that is used to call it. The parameters are appended to the URL in the format ?variablename = value[&variablename=value...]; for example www.MyCompany.com/inputpage.cfm?productCode=A12CD1510&quantity=3. Note: If a URL includes multiple parameters with the same name, the resulting variable in the ColdFusion URL scope consists of all parameter values separated by commas. For example, a URL of the form http://localhost/urlparamtest.cfm? param=1&param=2&param=3 results in a URL.param variable value of 1,2,3 on the ColdFusion page.
Variables (local) The default scope for variables of any type that are created with the cfset and cfparam tags. A local variable is available only on the page on which it is created and any included pages (see also the Caller scope).


23. What is Application Variables? How can you clear these variables?
These are special scope variables that are available to all pages in an application for all clients.
Data is stored in application server memory.
You must use the Application scope prefix in the variable name.

<!--- To delete all application variables--->
<cfset StructClear(Application)>
<!--- To delete a particular variable in session --->
<cfset StructDelete(Application, "varName")>


24. What is Session Variables? How can you clear these variables?
These are special scope variables that are available for a single client browser for a single browser session in an application.
Data is stored in application server memory.
You must use the Session scope prefix in the variable name.

<!--- To delete all session variables --->
<cfset StructClear(Session)>
<!--- To delete a particular variable in session --->
<cfset StructDelete(Session, "varName")>

25. How can you list out all the Session variables in an Application?
use cfdump to show entire session value in Development environment.

<cfdump var="#session#">

Session variables are in stored in structure format. So you loop through the collection to show the session variables.

<cfoutput><cfloop  collection=#session# item="key">
    #key# : #structFind(session,key)#<br />
</cfloop></cfoutput>

26. How can you delete the session variables?

<!--- To delete all session variables --->
<cfset StructClear(Session)>
<!--- To delete a particular variable in session --->
<cfset StructDelete(Session, "varName")>


27. What is a client variable?
These are special scope variables that are available for a single client browser over multiple browser sessions in an application.
Data is stored as cookies, database entries, or Registry values.
No need to use the Client scope prefix in the variable name
Value must be simple variables. Can not be arrays, structures, query objects, or other objects.

28. What is the default storage for client variable?
client variables stored in registry, database or in client cookie.By default, ColdFusion stores this in the Registry.it is more appropriate to store the information as client cookies or in a SQL database.

29. What is URL token?
Combination of CFID & CFTOKEN is called as urltoken. If user disabled the browser cookie, It is used to track a user's browser session.

30. What is Cookie Variables?
Cookies are server specific simply stored variables stored in files in the browser's file system. It used to track state maintenance(browser session) of a user.

31. What is the difference between Client and Session variables?
Session variables can be used to dump complex data structures like arrays and structures.But client variable are used only in case of simple variables.

32. What is Structure? What are the different functions in Structure?
ColdFusion structures consist of key-value pairs. Structures let you build a collection of related variables that are grouped under a single name. A structure's key must be a string. The values associated with the key can be any valid ColdFusion value or object. It can be a string or integer, or a complex object such as an array or another structure. Because structures can contain any kind of data they provide a very powerful and flexible mechanism for representing complex data. check Structure functions here.

33. What is the difference between Structure and Array?
In structure one can combine variables of different datatype in to a common data type Whereas arrays are sequentially stored values of the same datatype.

34. How can you set common footer?
Using cfinclude, we can include footer file in all pages. We can OnRequestEnd.cfm file or OnRequestEnd method in Application.cfc also to include footer file.

35. What is OnRequestEnd.cfm? When it will execute?
Just as the Application.cfm page runs before the code on an application page, an OnRequestEnd.cfm page runs, if it exists, after each application page in the same application.The OnRequestEnd.cfm page must be in the same directory as the Application.cfm page ColdFusion uses for the current page. ColdFusion does not search beyond that directory, so it does not run an OnRequestEnd.cfm page that resides in another directory.The OnRequestEnd.cfm page does not run if there is an error or an exception on the application page, or if the application page executes the cfabort or cfexit tag. Page flow given below

Application.cfm -> CFM page -> OnRequestEnd.cfm

36. Can we have multiple OnRequestEnd.cfm in an Application? How its works?
Yes, We can have. The OnRequestEnd.cfm page must be in the same directory as the Application.cfm page ColdFusion uses for the current page. ColdFusion does not search beyond that directory

39. Where we can place the custom tag?
Custom tags can be stored in any of the following locations. ColdFusion will search for them in the order listed.
    In the same directory as the calling page - while this is easy for demonstration purposes, it's not very practical, as it means that the custom tag is only available within that directory.
    In a directory (or subdirectory of a directory) specified in ColdFusion Administrator under Extensions -> Custom Tag Paths.
    In the cfusion/CustomTags directory or one of its subdirectories.

40. What are the different ways to call custom tag?
  using cf_  filename of custom tag
  using cfmodule tag
  using cfimport  tag

Coldfusion interview Questions with answers

ColdFusion 5 Comments »

Coldfusion interview Questions with answers :-

Only i given few anwsers for my 108 questions post. I will try to complete ASAP :)

Read more...

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds