Viewers: in countries Watching now:
In ColdFusion 9 New Features, author and developer Dan Short has gathered together the important updates and improvements in this dynamic web application. Dan showcases the new ColdFusion Builder application throughout the course, using it to work through the new language and CFScript enhancements in this release. He shows how to use the new Server Manager to compare servers and create server groups, as well as monitor server health through notifications. He also explains the new integration with Office applications, building Excel, Word, and even PowerPoint files on the fly from ColdFusion. Finally, he covers the important new Object Relational Mapping feature and how to use the built-in Flash Player. Exercise files accompany this course.
The new Server.cfc is a server-wide file that will run on every server start, allowing you to perform work to get the server setup and ready to go before any of your applications are actually started. In this video, I'll show you how to configure and make use of the Server.cfc. So to begin with we need to actually enable the Server.cfc and that's done inside the ColdFusion Administrator. So inside the ColdFusion Admin on the Settings page near the bottom here, we have Component with onServerStart method.
So this is going to be either an absolute path or a dot-delimited the path from the web root that determines where our Server.cfc is. By default ColdFusion will look in the Server CFC underneath the web root, if you don't specify one. So here we'll specify Chapter2.server, and now I check that box that says we are going to enable it. If I scroll down to bottom, I'll click Submit Changes. We see that the server has been updated successfully, so we can go back to CF Builder and take a look at our Server.cfc.
I'll open that file and in here we only have one method, which is onServerStart. This is the method that will be executed when the server actually spins up. So in this case what I'm going to do is send myself an email that tells me that the server has been started and then I'll set a server variable that says the date and time that server will start. So now that I have everything setup, let's go over here to Servers, right-click on my server, and choose Restart.
Now I'll switch over to the Console here, and we can see that it has stopped ColdFusion and it is now starting. Go ahead and make this larger. We can see that after everything that ColdFusion needed to do is finished, the last item here shows that it invoked the onServerStart method on CFC Chapter2.Server. So now if I go and check my email, I should have an email that tells me that the server has started. So go ahead and take a look at this email, and we can see that the server was started at 2009-09-15 at 3:40 in the afternoon.
So let's go back to CF Builder and double check that our server variable was set correctly. So what I'll do here is just create a new file to test with. I will call this scribble.cfm and we'll dump the server scope. If I view that here and take a look, we can see server.started is set to 2009-09-15 at 3:40 in the afternoon. So now you can see that the Server.cfc will allow us to send our emails when the server gets started. Setup server's scope variables, but as I said earlier there are some things it can't do, such as using any feature that requires the full server to be started.
For example, we can't use a cfhttp tag with a URL that specifies a location on the same server, and we can't use any application or request-scope variables in the method. Now if any error happens, you're not going to be notified at all. So make a habit of checking your server logs to be sure that your onServerStart is running correctly. So using the new Server.cfc gives you one more hook to let you know what's going on with your server. It provides a handy way to setup server-wide resources before any applications get kicked off.
There are currently no FAQs about ColdFusion 9 New Features.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.