[Looking for Charlie's main web site?]

Struggling with using the XML features of CFML? Here's where to learn more

Are you struggling with using the XML features in CFML? Or do you help people who are?

It's not something most people use often, and there is far more to the feature set than meets the eye. If you don't use the right resources to help you, you could waste time trying to piece together a solution using only scant examples you may find.

In this entry, I'll point to several resources you should consider to help get you quickly up to speed in using--and appreciating--the power of the XML features in CFML.

Even if you don't need them today, you (or someone you know) may need them some day, so keep this in mind. (Or if you find this page doing a google search some years down the road, drop a note to let me know if it helped then!)

Background

[....Continue Reading....]

Learning resource for beginning web developers

If you know anyone needing to learn the fundamentals of web application development--not CFML, but things like HTML, CSS, Javascript, and so on--here's an interesting resource: Beginner Developer Center, Tier 1

Yes, it's a MS resource: don't let that keep you away

Now, some will see this is from Microsoft and flinch, but don't let that scare you away. It's a set of introductory resources that could help any beginning web developer, and while the first 2 and last 2 of the 14 sections are MS-specific, the rest are not.

And besides the web-oriented topics above (HTML, CSS, Javascript, and more), there are also sections introducing basic programming concepts like problem solving, processing and storing data, even introducing OO (again, with no reference to C# or anything .NET), and more.

For each of the 14 topics, there is both an article-level discussion and either an audio or video version.

Yes, it's in a resource center about VWD. Don't let that scare you away, either

I'll note that beyond being "from MS", it's also indeed specifically part of a resource center for their Visual Web Developer IDE. Again, most of the content offered in this beginner resource is not really specific to that editor or to .NET.

And frankly, I wouldn't hold it against a CF developer to consider using the editor. Hey, it's free, and consider also that sometimes you may have to do some editing on a server with nothing but Notepad available. Perhaps you're not a fan of Eclipse, don't have an available license for DW/HS, and you want more than just Notepad. (Yes, I do also know about the many other available free (and some commercial) editor alternatives. I list them in my CF411 site category of Editors/IDEs.)

(And if you're ever stuck in a situation where you're unwilling or not allowed to install any new editor on your server, just last week I wrote about a tip for using Notepad if you ever find that you can't use the Goto Line feature.)

Anyway, the point is I'm not making a pitch here for VWD nor any statement against CFE. Let's not go there. :-) Indeed, to any who may want to take the chance to comment here in scorn or to deride the VWD editor or MS, or to point out some other editor alternative, let's not go there, either.

The point of this entry is the free learning resources for beginning web developers that I found on the MS site. I hope it may help some people.

CFFundamentals: Mimicking a form submission using CFHTTP

While developers who've used CFML for a long time will regard some topics as old hat, we have to remember that there are folks who either have come along recently or simply never used some feature. This is one of those topics, and since I answered it on a list, I offer it here.

I'd like to start doing that more often (reformatting some answer I give on some list, so that others may learn from it.) As in this case, I'll refer to such as CFFundamentals and create a category for them so that interested readers may find them more readily.

The problem

Someone wrote wanting to mimic (in CFML code) the submission of some data to a form that they saw happening within an Airborne Trackship (http://track.dhl-usa.com/TrackEmail.asp) page.

They saw that the form submitting to that allowed one to enter an email address and some tracking numbers to have a status email sent back to that address. Using "view source" in the browser, they observed that the form actually called a Javascript form which submitted the form to TrackEmail.asp?nav=TrackByEmail. Since this was on a page at http://track.dhl-usa.com/, they realized they'd need to submit to http://track.dhl-usa.com/TrackEmail.asp?nav=TrackByEmail.

They also noticed that the form had two input fields, txtTracknbrs and txtEmailAddress, so they tried to put together a CFHTTP request that tried to submit to the form using this URL:

http://track.dhl-usa.com/TrackEmail.asp?nav=TrackByEmail&txtTracknbrs=nnnnnnnnn&txtEmailAddress=someemail@address.com

It didn't work. They asked if anyone knew why.

My Response: He was close, but needed to understand a couple of points

Here's what I wrote:

I think your problem is in presuming that the Javascript method builds a request that looks like the one you tried in CFHTTP. I just reviewed the page, and I see that it's a form, with a METHOD=POST, and so your CFHTTP needs to send its info in the way a form post would. And that's NOT by passing the variables on the URL as you have. (One may argue that they can write CFML apps that accept either FORM or URL variables, but the page being called is an ASP page, so we can't make that presumption.)

With that, I changed your CFHTTP to the following and it worked (you should be getting an email soon, as it told me the request was accepted). Try it yourself:

<cfhttp url="http://track.dhl-usa.com/TrackEmail.asp" method="POST">
   <cfhttpparam type="URL" name="nav" value="TrackByEmail">
   <cfhttpparam type="FORMFIELD" name="txtTrackNbrs"
value="nnnnnnn">

   <cfhttpparam type="FORMFIELD" name="txtEmailAddress"
value="someemail@address.com">

</cfhttp>

<cfoutput>
#cfhttp.filecontent#
</cfoutput>

Note that it uses a TYPE="URL" for the nav query string value (as that WAS passed on the URL), but uses TYPE="FormField" for the form fields, since those are passed as form fields. You were right in getting the exact names of the form fields as used in the form fields of the form. That's critical as well.

I'll point out as well that when trying to mimic such forms in CFHTTP, it's also sometimes critical to send along any hidden form fields. There were two on that form, but I left them off and it seems to work. IF you found you needed to add them, just add them as more TYPE="FormField" values.

I should note as well that sometimes when trying to simulate a form submission, you will also need to send along any cookie values that might be being sent by your browser to the server. Those aren't shown in the form. You could use browser/server proxy tools (like the free Fiddler or Firebug tools) to detect what's being sent along.

Hope that may help other readers.

I'll add in this blog entry that regarding that last point, about using HTTP proxies to study the browser/server communication, I wrote about those previously in:

Alternatives HTTP debugging proxies, for debugging

BlogCFC was created by Raymond Camden. This blog is running version 5.005. (Want to validate the html in this page?)

Managed Hosting Services provided by
Managed Dedicated Hosting