Entries Tagged as 'Coldfusion'

Issue with Amazon S3 PDF download link in Chrome and Internet Explorer (IE)

Posted by Pritesh on January 30, 2012
  0 comments

In one of our project we are using Amazon S3 to store files which later use to download from web application. We have most of the files are in secure list and only accessible through web application. It was working fine for firefox but on chrome and Internet Explorer (specially PDF file) doesn't download or open in PDF Viewer plugin instead shows about:blank page client do not have any idea what going on. For tempory solution client able to download by right click on link and selecting save link to... option but this is not everybody going to do. 




Case Study: HauntWorld.com AWS implementation

Posted by Pritesh on January 07, 2012
  0 comments

 

ABOUT HAUNTWORLD

HauntWorld the most advanced haunted and Halloween attraction directory on the web. Hauntworld.com is dedicated to promoting the haunted house industry, which includes haunted houses, attractions, events and vendors who provide products and services.  HauntWorld helps to find haunted houses nationwide and additionally offer the national media information about the haunted house industry. Client running around 11 different sites on existing dedicated hosting servers.

EXISTING STRUCTURE

Existing infrastructure contains two application servers and one database server. App Server 1 holding mainly two high traffic websites built on ColdFusion and PHP and App Server 2 holding rest of the low traffic websites. Both application servers connected with database server (MSSQL and MySQL database) through LAN.

 




Strange ColdFusion issue, JRUN eating up to 50% of CPU.

Posted by Pritesh on October 31, 2011
  2 comments

 

For one of our project we recently move to Amazon EC2 to make system easily scalable. This is kind of seasonal website which has high traffic during September and October and rest of the year traffic reduced to 70% with compare to October month. I think Amazon's usage based model is perfect for this client as he doesn't need to pay much on his off season also we can easily scale and add new instances during peak season and cover cost that we saved during off season.

Finally we happily moved everything on cloud EC2 and working fine. Suddenly after 1 hour of so CPU usage increased to 50% and remain constance 50% for hour or so. While looking into Task manager we realize that JRUN is eating up that CPU but there wan't much traffic at that time (average 1 user/sec) and system was happily handling this much traffic in our dedicated server. Tried to install Fusion Reactor to see realtime users and other stats but it seem that even Fusion Reactor can not figure out who is eating up CPU. For a day we keep running server as our all sites working correctly and wasn't making much performance issue.

 




Configure ColdFusion with VisualVM.

Posted by Pritesh on October 31, 2011
  0 comments

For one of our project we are facing jrun high usage issue. When looking into task manager (Window 2008) I found jRun continously eating up 50% CPU usage even though there is no traffic (or may be 2 to 3 users) only on site. Initially I tried to install FusionReactor to get all kind of detail regarding ColdFusion. Started with trial version and thought if useful then get full version but it seems that giving me all application ColdFusion application related information but can't find anything why JRun eating 50% of CPU usage. After bit googing I found VISUALVM and JConsole for monitoring and troubleshooting java application. I like VisualVm due to it's nice GUI and also I can integrate JConsole as plugin to it. It win - win kind of situation. 




Complex password strength checking through regular expression

Posted by Pritesh on September 20, 2011
  0 comments

Currently working on project for well non credit card company where they have online registration form. They really want user enter enter strong password for their account and criteria for password listed below..

  1. Password must length between 8 to 18.
  2. Password must contain atleast one alpha and on numeric.
  3. Password must have one special characters from @,#,$.
  4. Password can not have repeative alpha and numeric.

This is really complex but can be done with four different conditions easily (right?) but I decided to make things more complex and check all four condition with single regular expression. After spending time on this finally figure out regular expression can perform all four condition.




Read File line by line in ColdFusion by using Java Classes

Posted by Vikas on September 20, 2011
  3 comments

HI,
I was having situation where I wanted to read a file and process each line.
I think cffile tag is not much to do it, so I use java classes.
Basically we need two kinds of classes.
1. InputSream
2. Buffer reader

Buffer reader is capable to read any input stream line by line.

Final code will look like:



<cfscript>

    FileName = expandPath('/temp.txt');

    objFileReader = createObject("java","java.io.FileReader");

    InputStreamReader = objFileReader.init(FileName);

    objBuffer = createObject("java","java.io.BufferedReader" );

    LineIO = objBuffer.init(InputStreamReader);

</cfscript>



<cfset eof = 0>

<cfset cnt = 1>

<cfloop condition="not eof">

    <cfset currline = LineIO.readline()>

    <cfif isdefined("currline") eq "no">

        <cfset eof = 1>

        <cfbreak>

    </cfif>

    <cfoutput>line #cnt#: #currline#<br/></cfoutput>

    <cfset cnt = cnt + 1>

    <cfflush>

</cfloop>





Static method implementation in ColdFusion

Posted by Vikas on September 04, 2011
  0 comments

I found some discussion about static method equivalence in ColdFusion.

In C# we can declare class as static and static class can only have all the static methods and static variables. And we can call static class methods without creating its instance.

In ColdFusion we must need to create an instance of cfc. Then & then we can call it’s method. To avoid creating instance each time, you can create object in Application init() function, and make it at application scope, so you can directly call the methods. But this is still a nasty approach, as we are still creating an object when Application initializes.

Then I remember that ColdFusion is not an Object Oriented Language. We make it look like OOP! It happens mostly when we use ColdBox or Model Glue or any other application framework, where most of the coding is in cfc only. Now a days people are using cfscript tag more as Lots of tags are now available in cfscript. And when we use cfscript tag we, feel like it's an OOP language! But remember ColdFusion is a scripting language as PHP and Classic asp. cfscript tag itself trying to remind us by its name!

Thanks...




Work around ColdFusion local scope

Posted by Vikas on August 19, 2011
  0 comments

Hi friends,

 

These days am working as a tester. I never thought that developer can also do that if they really take interest in testing! Infect someone can also learn from the testing, even testing can also test their understanding for knowledge.

 

While testing I saw one case where I get more variable in the array object other then I defined. Then I again take a look and I came to know that local variable was causing an issue.

Let me give you some examples and exercise. Make sure that before you see the output just think what would be the output. Consider that all following code is written in sample cfml page and we are using ColdFusion 9.




Bug - count() function in ColdFusion query of query

Posted by Vikas on August 17, 2011
  0 comments

 

Hi,

It has been a great time since I started working on ColdFusion. I must say that it is the easiest language in the world and yet it is a powerful and can be compared to any major programming language.

In last few days, I was using ColdBox and MockBox framework in our current project. I was using query of query which is very similar to SQL query, and we can use it over query object in ColdFusion.

Count() is a math function, but if we use it with select statement like count(*), it returns a number of rows fetched in select query. I used it query of query, and it was giving me the correct count if my select statement is returning some rows, but if it is not returning any row then ideally it should give 0 as output, but it gives [empty string].

 




How to use query of query in cfscript

Posted by Nirav Patel on August 06, 2011
  0 comments

We can use queries of queries in cfscript with the Query.cfc. But this is possible in Coldfusion 9 because Query.cfc has introduced in Coldfusion 9.

Let's see the following code.

<cfquery name="qRead" datasource="#application.dsn#" username="#application.dbuid#" password="#application.dbpwd#">
    SELECT employeeId,fistName,LastName FROM employees
</cfquery>
<cfscript>
    qoq = new Query(sql="select * FROM qRead WHERE employeeId=1", dbtype="query", qRead = qRead);
    qList = qoq.execute().getResult();
</cfscript>

I am just passing the my sql statement to sql argument and the dbtype value will be the 'query'. Here I'm pass qRead as the 3rd argument. If I am not pass this qRead then I got error as :

Error Executing Database Query. Query Of Queries runtime error. 
Table named qRead was not found in memory. The name is misspelled or the table is not defined.

This is because, I have the qRead in my cfml page's variable scope but I'm trying to execute the query of query on the Query.cfc and qRead was not on cfc's variable scope. Both the cfml page's variable scope and the cfc's variable scope are different and they do not have access to eachother.

But when I'm passing the qRead as argument, the init() function of the Query.cfc copy the named arguments into the local Variables scope and then while executing the query of query qRead available in the variable scope of the Query.cfc and we got the result.

 

For better understanding please see the blog from Ben Nadel:

http://www.bennadel.com/blog/2224-Performing-Query-Of-Queries-Using-ColdFusion-9-s-Query-cfc-Component.htm